(1)写出建立该表的sql语句
(2)找出nickname为qq的用户,按id降序排列的sql语句
(3)写出删除id为1234用户记录的sql语句
(4)写出添加id为5555,nickname为’1234′的sql语句
答案:
(1)CREATE TABLE tableqq(
id int not null,
nickname char(20) not null)
(2)SELECT * FROM tableqq WHERE nickname = 'qq' ORDER BY id DESC
(3)DELETE FROM tableqq WHERE id = 1234
(4)INSERT INTO tableqq VALUES(5555,'1234')
2. 有关系 s(sno,sname) c(cno,cname) sc(sno,cno,grade)
1 问上课程 “db”的学生
select s1.sname from s s1,c c1,sc sc1 where s1.sno = sc1.sno and sc1.cno = c1.cno and c1.cname = 'db'
2 成绩最高的学生号
select sno,max(grade) from sc group by sno
3 每科大于90分的人数
select cno,count(sno) from sc where grade > 90 group by cno;