select 语句问题,,帮忙看下

来源:百度知道 编辑:UC知道 时间:2024/06/01 17:54:39
题目是:
请写出在class表中查找满足如下条件的记录的SQL语句
1,返回字段 c_name,c_stu
2,返回记录数:前5条
3,查询条件:c_stu值大于30,并且 c_type值为真,并且c_name字段值中有
"二班"两个字
4,查询结果按c_stu正排序,按c_type倒排序(注:真排序不要省略关键字)
我写的答案是select top5 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
为什么不对?哪里错了吗?/
-----------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
楼下三位说的都不对啊@,改了一样错!--------------------
--------------------------------------------------------------------
--------------------------------------------------------------------
--------------------------------------------------------------------
--------------------------------------------------------------------

select top(5) [c_name],[c_stu] from [class] where [c_stu]>30 and [c_type] is true and [c_name] like '%二班%' order by [c_stu] asc,[c_type] desc
给你个建议,把列名表名都用[]号括起来,养成良好习惯

补充:我告诉你为什么都是错的,因为那个flash制作有问题!死读书只会害你的,换个地方学吧

select top5 c_name,c_stu from class where c_stu>30 and c_type is true and c_name like "*二班*" order by c_stu asc,c_type desc

like "*二班*"
这里是单引号

你的class表有没有问题?c_type的值是什么?要是1或0就改为c_type=1或0(哪个为真就写哪个)
select top 5 c_name,c_stu from class where c_stu>30 and c_type is true and c_name like '%二班%' order by c_stu asc,c_type desc