求核对一下SQL语句

来源:百度知道 编辑:UC知道 时间:2024/05/15 02:24:44
本人在学习FIF多媒体ASP互动教程的时候,碰到一个问题,现请大家帮我看一下,我写的SQL语句

错在哪里!
题目如下:

请写出在class和stu表中查找满足如下条件的记录的SQL语句:
1.表class中的字段c_id与stu表中的s_cid为关联字段
2.返回字段c_name,s_no,s_name
3.查询条件:c_stu字段值大于20,并且s_no第二位到四位是“006”这三个字符的
4.查询结果按s_no倒排序
注:因为两个表中的字段没有重名,因此写本条SQL语句时字段名前不用加表名

我写的语句是:

select c_name,s_no,s_name from class,stu where c_id=s_cid and c_stu>20 and s_no like

'?006' order by s_no desc

但是这个结果通不过互动教程,后面的内容就无法看到,多谢各位大侠的指点,在此多谢了!
select c_name,s_no,s_name from class,stu where c_id=s_cid and c_stu>20 and s_no like '?006*' order by s_no desc
这个是正确的答案,其实和写的对了一下,只是一个通配符的问题,在此谢谢各位!

select c_name,s_no,s_name from class,stu where c_id=s_cid and c_stu>20 and substring(s_no,2,3)='006' order by s_no desc
或者是
select c_name,s_no,s_name from class,stu where c_id=s_cid and c_stu>20 and s_no like'_006%' order by s_no desc

select c_name,s_no,s_name from class A,stu B

where A.c_id=B.s_cid
and c_stu>20
and s_no like '?006'
GROUP BY c_name,s_no,s_name

order by s_no desc

select c_name,s_no,s_name from class,stu where c_id=s_cid and c_stu>20 and s_no like '_006?' orderBy s_no desc
看一下行不行