我有 3 個表,分別是 product、category 和 product_category。如何在我的管理面板的表格中顯示具有多個類別的產(chǎn)品? product table category table product_category table +---+------------+ +---+------------+ +-----------+------------+ |id | name | |id | name | |product_id | category_id|+---+------------+ +---+------------+ +-----------+------------+ | 1 | Cake | | 1 | Sweets | | 1 | 1 || 2 | Chocolate | | 2 | Dessert | | 1 | 2 |+---+------------+ +---+------------+ | 2 | 1 | | 2 | 2 | +-----------+------------+我嘗試創(chuàng)建一個“鏈接表”,但是當(dāng)我嘗試獲取數(shù)據(jù)時,它給了我多行。$query = mysqli_query($con, "SELECT * FROM product, category, product_category WHERE product.product_id=product_category.product_id AND product_category.category_id=category.category_id");它給了我這個輸出:+-------------+------------+ |product name | category |+-------------+------------+ | Cake | Sweets || Cake | Dessert || and so on... |+-------------+------------+ 但我希望它看起來像這樣:+-------------+--------------------+ |product name | category |+-------------+--------------------+ | Cake | Sweets,Dessert || and so on... |+-------------+--------------------+
- 1 回答
- 0 關(guān)注
- 168 瀏覽
添加回答
舉報
0/150
提交
取消
