我有多個表如下:MySQL查詢,以避免重複結果
表1:產品
+-----+----------+--------+---------------------+
| id | biz_id | name | message |
+-----+----------+--------+---------------------+
| 1 | 1 | test1 | One tow three |
| 2 | 1 | test1 | One tow three |
| 3 | 1 | test1 | One tow three |
| 4 | 2 | test2 | hello world |
| 5 | 2 | test2 | hello world |
+-----+----------+--------+---------------------+
表2:圖片
+-----+----------+--------------+-------------------+
| id | biz_id | product_id | path |
+-----+----------+--------------+-------------------+
| 1 | 1 | 1 | img/qwert1.jpg |
| 2 | 1 | 2 | img/qwert2.jpg |
| 3 | 1 | 3 | img/qwert3.jpg |
| 4 | 2 | 4 | img/qwery4.jpg |
| 5 | 2 | 5 | img/qwert5.jpg |
+-----+----------+--------------+-------------------+
如何避免在連接多個表時在mysql中重複?
我的查詢是加入這兩個表,以便我想避免重複的產品(獲取Distint產品的名稱)並獲取與該產品相關的所有圖像(例如Product> name - test1 has images qwert1.jpg,qwert2.jpg ,qwert2.jpg)
將所期望的結果是什麼樣的? – Strawberry