create table student (name varchar(12), grad_year int)
insert into student (name, grad_year) values ('xxx', 2000)
insert into student (name, grad_year) values ('yyy', 2000)
insert into student (name, grad_year) values ('zzz', 2000)
insert into student (name, grad_year) values ('aaa', 2001)
insert into student (name, grad_year) values ('bbb', 2001)
insert into student (name, grad_year) values ('ccc', 2001)
select name, grad_year from student
查询结果
xxx, 2000
yyy, 2000
zzz, 2000
aaa, 2001
bbb, 2001
ccc, 2001
update student set grad_year = 2000 where name = 'aaa'
delete from student where name = 'zzz'
select name, grad_year from student where grad_year = 2000
查询结果
xxx, 2000
yyy, 2000
aaa, 2000
select name, grad_year from student where grad_year = 2000 and name = 'xxx'
查询结果
xxx, 2000
create table student (sid int, sname varchar(12), grad_year int, major_id int)
insert into student (sid, sname, grad_year, major_id) values (1, 'joe', 2004, 10)
insert into student (sid, sname, grad_year, major_id) values (2, 'amy', 2004, 20)
insert into student (sid, sname, grad_year, major_id) values (3, 'max', 2005, 10)
insert into student (sid, sname, grad_year, major_id) values (4, 'sue', 2005, 20)
insert into student (sid, sname, grad_year, major_id) values (5, 'bob', 2003, 30)
insert into student (sid, sname, grad_year, major_id) values (6, 'kim', 2001, 20)
insert into student (sid, sname, grad_year, major_id) values (7, 'art', 2004, 30)
insert into student (sid, sname, grad_year, major_id) values (8, 'pat', 2001, 20)
insert into student (sid, sname, grad_year, major_id) values (9, 'lee', 2004, 10)
create table dept (did int, dname varchar(12))
insert into dept (did, dname) values (10, 'compsci')
insert into dept (did, dname) values (20, 'math')
insert into dept (did, dname) values (30, 'drama')
select sid, sname, grad_year, did, dname from student, dept where major_id = did
查询结果
1, joe, 2004, 10, compsci
2, amy, 2004, 20, math
3, max, 2005, 10, compsci
4, sue, 2005, 20, math
5, bob, 2003, 30, drama
6, kim, 2001, 20, math
7, art, 2004, 30, drama
8, pat, 2001, 20, math
9, lee, 2004, 10, compsci