0
我試圖爲每個產品顯示一行,但每個產品都有多個值。 這就是我想:MySQL Select,在列上顯示一行並顯示多個值
select pr.ID_PRO, pr.NOMBRE_PRODUCTO, img.DIRECCION, m.MARCA_NOMBRE from
productos pr INNER JOIN
img_pro img ON pr.ID_PRO = img.FOR_PRO INNER JOIN
mm_productos_marca pm ON pm.ID_PRO = pr.ID_PRO INNER JOIN
marca m ON m.ID_MAR = pm.ID_MAR;
結果:
+--------+-----------------+---------------------------+--------------+
| ID_PRO | NOMBRE_PRODUCTO | DIRECCION | MARCA_NOMBRE |
+--------+-----------------+---------------------------+--------------+
| 1 | asdasd | images/discos-esmeril.jpg | ABRATOOLS |
| 1 | asdasd | images/lol.png | ABRATOOLS |
| 2 | 123qwe1 | images/images.jpg | ABRATOOLS |
| 2 | 123qwe1 | images/images.jpg | BRAND |
+--------+-----------------+---------------------------+--------------+
慾望結果:
+--------+-----------------+---------------------------+--------------+
| ID_PRO | NOMBRE_PRODUCTO | DIRECCION | MARCA_NOMBRE |
+--------+-----------------+---------------------------+--------------+
| 1 | asdasd | images/discos-esmeril.jpg | ABRATOOLS |
| | | images/lol.png | |
+--------+-----------------+---------------------------+--------------+
| 2 | 123qwe1 | images/images.jpg | ABRATOOLS |
| | | | BRAND |
+--------+-----------------+---------------------------+--------------+
您正在尋找[GROUP BY](https://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html) –
@DipenShah http://prntscr.com/88rrf7這是結果。 –
這不是你想要的嗎? –