1:mysql的内连接:
内连接(inner join):显示左表以及右表符合连接条件的记录;
1 select a.goods_id,a.goods_name,b.cate_name
2 from tdb_goods a,tdb_goods_cate b
3 where a.cate_id = b.cate_id;
4
5 《==============上下两种写法等价===============》
6
7 select c.goods_id,c.goods_name,d.cate_name
8 from tdb_goods c INNER JOIN tdb_goods_cate d
9 on c.cate_id = d.cate_id;
2:外连接(左外连接,右外连接):
左外连接(left join):显示左表的全部记录以及右表符合连接条件的记录;
右外连接(right join):显示右表的全部记录以及左表符合连接条件的记录;
1 select c.goods_id,c.goods_name,d.cate_name
2 from tdb_goods c LEFT JOIN tdb_goods_cate d
3 on c.cate_id = d.cate_id;
4
5
6 select c.goods_id,c.goods_name,d.cate_name
7 from tdb_goods c RIGHT JOIN tdb_goods_cate d
8 on c.cate_id = d.cate_id;
不断深入的熟悉之前不熟悉的知识点,这也是进步......
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有