0

I have query which returns this result:

+-----------------------------------------+
| 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.                      |
+-----------------------------------------+

it would return 6 rows in total as you can see.

I would like to return all records in only one row. Is that possible?

Here is the query to visualize things better:

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';

Thanks in advance.

escobarveras
  • 69
  • 2
  • 8
  • 1
    Check the [GROUP_CONCAT](https://dev.mysql.com/doc/refman/5.6/en/aggregate-functions.html#function_group-concat) function – shree.pat18 May 25 '22 at 02:25

1 Answers1

0
SELECT GROUP_CONCAT(product_english ', ')
FROM menuBreakfast  
WHERE breakfast_id = 'B1';

Also you can apply concat

SELECT concat(product_english ) as product_english FROM menuBreakfast  
WHERE breakfast_id = 'B1'; 
Damini Suthar
  • 1,470
  • 2
  • 14
  • 43