When the number of join data is also more than one, how to show it?

SELECT
          t.name AS tname
        FROM `product` as p
        JOIN
          `product_theme` as pt ON pt.prod_id = p.prod_id
        JOIN
          `theme` as t ON t.theme_id = pt.theme_id

theme
clipboard.png

product_theme
clipboard.png

product theme
product_theme prod_id

tname

while ($row...mysqli_fetch_array) $row["tname"] prod_id 41 theme

clipboard.png

so how do I show and rewrite it?

Mar.23,2021

according to your needs, you can use the group_concat function and display it in groups by prod_id. The SQL is similar to the following:

select proid_id,group_concat(t.name SEPARATOR ';') as tname from product as p .....  group by prod_id

the result is similar:

proid_id      tname
...
40            
41            ;
...

in this way, $orw ['tname'] in the program gets "the best warm bag in summer; the world of Komatsu Sinai", which can be divided into arrays with the explode function.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bed11e-31b43.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bed11e-31b43.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?