关于sql语句的一个简单问题,帮忙啊,谢谢!!!

来源:百度知道 编辑:UC知道 时间:2024/05/21 16:43:04
题目是:
请写出在class表中查找满足如下记录条件的sql语句:
1.返回字段c_name,c_stu;
2.返回记录数:前5条;
3.查询条件:c_stu值大于30,并且c_type值为真,并且c_name字段值中有“二班”两个字。
4.查询结果c_stu按正排序,c_type按降排序。
我写的语句是:
select top 5 c_name,c_stu from class where c_stu>30 and c_type=true and c_name like '*二班*' order by c_stu asc and c_type desc.
但这是错误的,该写成什么样的才是对的啊,苦恼中,希望大家指点下,谢谢了!!!!!!
谢谢1,2楼的先,但我试了下,是错误的。

and c_name like '*二班*' order by c_stu asc and c_type desc.

改为:and c_name like '%二班%' order by c_stu asc,c_type desc

select top 5 c_name,c_stu from class where c_stu>30 and c_type=true and c_name like '*二班*' order by c_stu asc,c_type desc

如果你想通过FIF的互教程的话,那以上就是答案!本人亲测!

select top 5 c_name,c_stu from class where c_stu>30 and c_type='true' and c_name='%二班%' order by c_stu asc and c_type desc

从新试下这个select top 5 c_name,c_stu from class where c_stu>30 and c_type='true' and c_name like '%二班%' order by c_stu asc and c_type desc

试一下这个:
select top 5 c_name,c_stu from class where c_stu>30 and c_type='true' and c_name matches '*二班*' order by c_stu asc and c_type desc

select top 5 c_name,c_stu from class where c_stu>30 and c_type='true' and c_name like '%二班%' order by c_stu asc,c_type desc

注意:
1,多条件排序只能使用","