查询语句:1、“select * from 表名;”,可查询表中全部数据;2、“select 字段名 from 表名;”,可查询表中指定字段的数据;3、“select distinct 字段名 from 表名”,可对表中数据进行去重查询。
select www.sychzs.cn,score from (select id,age from stu where age < 20) a (过滤左表信息) left join (select id, score from result where score < 60) b (过滤右表信息) on www.sychzs.cn = www.sychzs.cn;
左外连接就是左表过滤的结果必须全部存在。如果存在左表中过滤出来的数据,右表没有匹配上,这样的话右表就会出现NULL;
(2)右外连接查询
select www.sychzs.cn,score from (select id,age from stu where age < 20) a (过滤左表信息) right join (select id, score from result where score < 60) b (过滤右表信息) on www.sychzs.cn = www.sychzs.cn;
左外连接就是左表过滤的结果必须全部存在
如图:
select www.sychzs.cn,score from (select id,age from stu where age < 20) a (过滤左表信息) inner join (select id, score from result where score < 60) b (过滤右表信息) on www.sychzs.cn = www.sychzs.cn;
【相关推荐:mysql视频教程】