mysql全外和交叉&&sql92pksql99
1 #全外 2 use girls; 3 SELECT b.*,a.* 4 FROM beauty b 5 FULL OUTER JOIN boys a 6 on b.boyfrien_id=a.id; 7 8 #交叉连接99标准笛卡尔乘积 9 SELECT b.*,ob.* 10 FROM beauty b 11 CROSS JOIN boys ob; 12 13 #sql92和sql99pk 14 #功能:sql99支持的较多 15 #可读性:sql99实现连接条件和筛选条件分离,可读性较高 16 17 #一、查询编号>3的女神的男朋友信息,如果有则列出详细,如果没有,用nu11填充、 18 SELECT b.id,b.name,be.* 19 FROM beauty b 20 LEFT OUTER JOIN boys be 21 ON b.boyfriend_id=be.id 22 and b.id>3; 23 24 #二、查询哪个城市没有部门 25 USE myemployees; 26 SELECT city 27 FROM locations l 28 LEFT OUTER JOIN departments d 29 on d.location_id=l.location_id 30 WHERE d.department_id is null; 31 32 #三、查询部门名为SAM或IT的员工信息 33 SELECT e.*,d.department_name 34 FROM employees e 35 LEFT OUTER JOIN departments d 36 on e.department_id=d.department_id 37 WHERE d.department_name in('SAL','IT');
本文来自博客园,作者:自律即自由-,转载请注明原文链接:https://www.cnblogs.com/deyo/p/13268197.html