如何将 concat/append 多个返回行合并为一行?
How to concat/append multiple returned rows into only one row?
我想查询 return 这个结果:
+-----------------------------------------+
| product_english |
+-----------------------------------------+
| can of orange juice |
| oatmeal container |
| milk bottle 28 oz |
| chocolate powder no sugar added - 16 oz |
| instant coffee 8 oz container |
| almonds bag 25 oz. |
+-----------------------------------------+
如您所见,总共 return 6 行。
我想return所有记录只在一行中。这可能吗?
下面是更好地可视化事物的查询:
SELECT product_english
FROM menuBreakfast mb
JOIN productPerMenu ppm ON ppm.menu_id = mb.breakfast_id
JOIN productList pL on ppm.product_id = pL.product_id
WHERE breakfast_id = 'B1';
提前致谢。
SELECT GROUP_CONCAT(product_english ', ')
FROM menuBreakfast
WHERE breakfast_id = 'B1';
你也可以申请concat
SELECT concat(product_english ) as product_english FROM menuBreakfast
WHERE breakfast_id = 'B1';
我想查询 return 这个结果:
+-----------------------------------------+
| product_english |
+-----------------------------------------+
| can of orange juice |
| oatmeal container |
| milk bottle 28 oz |
| chocolate powder no sugar added - 16 oz |
| instant coffee 8 oz container |
| almonds bag 25 oz. |
+-----------------------------------------+
如您所见,总共 return 6 行。
我想return所有记录只在一行中。这可能吗?
下面是更好地可视化事物的查询:
SELECT product_english
FROM menuBreakfast mb
JOIN productPerMenu ppm ON ppm.menu_id = mb.breakfast_id
JOIN productList pL on ppm.product_id = pL.product_id
WHERE breakfast_id = 'B1';
提前致谢。
SELECT GROUP_CONCAT(product_english ', ')
FROM menuBreakfast
WHERE breakfast_id = 'B1';
你也可以申请concat
SELECT concat(product_english ) as product_english FROM menuBreakfast
WHERE breakfast_id = 'B1';