我有兩個表:選擇顯示
products
id | name | brand | desc
1 pencil brand1 desc1
2 paper brand2 desc2
3 books brand1 desc3
4 pen brand2 desc4
5 crayons brand1 desc5
和:
supplier
id | name | brand
1 sup1 brand1
2 sup2 brand2
我將如何顯示與brand1
下supplier brand
對相關聯的所有的產品和信息例如:如果供應商brand1
想要查看所有產品,他會看到以下信息:
我預計這種結果
products
id | name | brand | desc
1 pencil brand1 desc1
3 books brand1 desc3
5 crayons brand1 desc5
我是否需要連接查詢的?有更簡單的方法嗎?我只希望有人能幫我解決這個問題,即時通訊使用php和phpmyadmin,只要能在供應商表格下顯示具體結果,任何形式的代碼都會執行。
SELECT * FROM表1 LEFT JOIN上table1.id = table2.id表2試試這個 – mhmd