我有這個表:的mysql:一對多本身並加入
id name parent_id
0 fruit NULL
1 place NULL
2 apple 0
3 orange 0
4 beach 1
5 forest 1
,我希望得到這樣一個結果:
id name name
0 fruit NULL
1 place NULL
2 apple fruit
3 orange fruit
4 beach place
5 forest place
我試圖用這樣的:
SELECT * FROM foobar LEFT OUTER JOIN foobar c ON c.parent_id = c.id
但它不起作用。
這可能已經被谷歌搜索了。 – KrazzyNefarious