SQL语句:

来源:百度知道 编辑:UC知道 时间:2024/05/20 06:26:07
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 class.c_id = stu.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 class.c_id = stu.s_cid

and c_stu > 20 and substring(s_no,2,3) = '006'

select c_name,s_no,s_name
from class,stu
where c_id=s_cid
and c_str>20
and s_no like \'_006%\'
order s_no desc