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;
不断深入的熟悉之前不熟悉的知识点,这也是进步......