看了很多人的评论说不好理解,其实换个思路就好理解了,就是把parent_id里的数字替换成type_name,用这个思路来理解就清晰多了。
2019-01-24
SELECT p.type_id,p.type_name,s.type_name
FROM tdb_goods_types AS p
LEFT JOIN tdb_goods_types AS s
ON s.parent_id = p.type_id ;
SELECT s.type_id,s.type_name,p.type_name
FROM tdb_goods_types AS s
LEFT JOIN tdb_goods_types AS p
ON p.parent_id = s.type_id ;
结果一样,但人已晕
FROM tdb_goods_types AS p
LEFT JOIN tdb_goods_types AS s
ON s.parent_id = p.type_id ;
SELECT s.type_id,s.type_name,p.type_name
FROM tdb_goods_types AS s
LEFT JOIN tdb_goods_types AS p
ON p.parent_id = s.type_id ;
结果一样,但人已晕
2019-01-15
关于用户变量和局部变量不懂的可以看看这个
https://my.oschina.net/dslcode/blog/1602347
https://my.oschina.net/dslcode/blog/1602347
2019-01-07