表tb_score,id, student_id, lecture, score; tb_student的id和tb_score的student_id是相关联的;
要求写出:
1、gender = 男性,lecture = 数学,score > 70且score < 80的信息,需要select出来name,lecture,score;且按照tb_student的id正序且score逆序排序,限制100条数据;
2、会全表查询吗?
3、去掉score排序会全表查询吗?
sql写法:
select t_student.name, lecture, score from tb_student as t_student join tb_score t_score on t_student.id = t_score.student_id where t_student.gender = '男性' and lecture = '数学' and score > 70 and score < 80 order by t_student.id asc, t_score.score desc limit 100;
请教下,如何才不可以全表扫描???
全部评论
(4) 回帖