我有2個表。使用查詢獲取父&子數據
(1)稅:父表
id title
1 service tax
2 vat
(2)cess_taxes:子表
id tax_id title
1 2 cess vat
2 1 cess service
3 1 add. service
我想下面數據,
id title*
1 service tax (parent)
2 cess service (child)
3 add. service (child)
4 vat (parent)
5 cess vat (child)
如何使用查詢獲取數據?
我試圖與左,右&內加入
SELECT t.id, t.title, c.id, c.title
FROM `taxes` AS t
LEFT JOIN cess_taxes AS c ON c.tax_id = t.id
還有,你試過這麼遠嗎? – Prix
爲什麼downvote ??? –