Mysql中on,in,as,where的区别

答:Where查询条件,on内外连接时候用,as作为别名,in查询某值是否在某条件里 创建2个表:student,score student: score:

答:Where查询条件,on内外连接时候用,as作为别名,in查询某值是否在某条件里

创建2个表:student,score

student:

 score:

where

SELECT * FROM student WHERE s_sex='男'

例如:on

SELECT * FROM student LEFT JOIN score on student.s_id=score.s_id;

on和where组合:

SELECT * FROM student LEFT JOIN score on student.s_id=score.s_id WHERE s_name='赵雷' 

 

例如:in

SELECT * FROM score WHERE s_id in (SELECT s_id FROM student WHERE s_name='赵雷')

 

as

select * from score as a LEFT JOIN student as b on a.s_id=b.s_id where s_name='赵雷'