去哪上班认识有钱人:SQL查询语句

来源:百度文库 编辑:神马品牌网 时间:2024/05/03 07:36:34
在看FIF的SQL语句教程,第三课的复习题:
请写出在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=ture 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=1 and c_name like \'*二班*\' order by c_stu asc,c_type desc

c_type 数据类型为bit?

like '*二班*'

like '%二班%'

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