day20
关联查询
#左连接:表名 left join 表名 以左表为主表,只显示与左表能匹配的行
SELECT s.*,q.* FROM student AS s LEFT JOIN queue_info AS q ON s.q_id = q.id;
#右链接:以右边的表为主表,只显示与右表能匹配的行
SELECT s.*,q.* FROM student AS s RIGHT JOIN queue_info AS q ON s.q_id = q.id;
#内连接:只显示两边都能匹配上的行
SELECT s.*,q.`name` FROM student AS s INNER JOIN queue_info AS q ON s.q_id = q.id;
多表联查
#多表联查:和内连接差不多,都是只显示多表都能匹配上的行,只有查询的语法不同
SELECT s.*,q.* FROM student AS s,queue_info AS q WHERE s.q_id = q.id;
标签:info,20,id,queue,student,多表,day,SELECT
From: https://www.cnblogs.com/xiaoto9426/p/16834683.html