In [16]:
show databases
Database
0 information_schema
1 raj
In [1]:
use raj
yes
In [3]:
show tables
Tables_in_raj
0 BUILDING
1 MEDIA
2 ROOM
3 ROOMMEDIA
In [4]:
insert into BUILDING values ("SUN","Sunderraman Building")
yes
In [5]:
select bcode from BUILDING
bcode
0 25PP
1 ADHOLD
2 ARTS
3 CLSO
4 COE
5 COMMON
6 KELL
7 LANGDL
8 LIBSO
9 NSC
10 PIED
11 PSC
12 SPARKS
13 SUN
14 URBAN
In [6]:
select bcode,bname from building
bcode bname
0 25PP 25 Park Place
1 ADHOLD Adherhold Learning Center
2 ARTS Art & Humanities Bldg
3 CLSO Classroom South Bldg
4 COE College of Education
5 COMMON University Commons
6 KELL Kell Hall
7 LANGDL Langdale Hall
8 LIBSO Library South
9 NSC Natural Science Center
10 PIED Piedmont Hall
11 PSC Petit Science Building
12 SPARKS Sparks Hall
13 SUN Sunderraman Building
14 URBAN Urban Life Bldg
In [22]:
select * 
from building
(1096, 'No tables used')
In [8]:
select * from building where bcode = 'SUN'
bcode bname
0 SUN Sunderraman Building
In [9]:
select * from building where bcode like 'L%'
bcode bname
0 LANGDL Langdale Hall
1 LIBSO Library South
In [2]:
select 
    rnumber,cap
from   
    room, building
where  
    bname = 'Langdale Hall' and
    room.bcode = building.bcode and 
    cap >= 80;
rnumber cap
200 118
300 122
400 121
500 122
600 120
700 120
In [11]:
describe room
Field Type Null Key Default Extra
0 bcode varchar(6) NO PRI None
1 rnumber varchar(4) NO PRI None
2 cap int(11) YES None
3 layout varchar(20) YES None
4 type enum('P','G') YES None
5 dept varchar(4) YES None
In [4]:
select 
    rnumber,cap 
from 
    room,building 
where 
    room.bcode=building.bcode and
    cap >= 80 and 
    room.bcode = 'LANGDL';
rnumber cap
200 118
300 122
400 121
500 122
600 120
700 120