帮忙用access的sql语言写一下

来源:百度知道 编辑:UC知道 时间:2024/05/22 14:49:20
请写出在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 mid(s_no,2,3)='006' order by s_no desc

在sql server 2000 如下

select c_name,s_no,s_name from class,stu where c_id = s_cid and c_stu>20 and substring(str(s_no),2,3)='006'

以上s_no为数值型


select c_name,s_no,s_name from class,stu where c_id = s_cid and c_stu>20 and substring(str(s_no,len(s_no)),2,3)='006'