MySQL - Return all items in one row.
MySQL - Return all items in one row.
112
27-Jul-2023
Updated on 28-Jul-2023
Aryan Kumar
28-Jul-2023Sure, you can use the
GROUP_CONCAT()
function to return all items in a single row in MySQL. The syntax is as follows:SQL
For example, if you have a table called
products
with the columnsname
andprice
, you could use the following query to return all product names in a single row:SQL
This would return a single row with a comma-separated list of all product names.
Here is an example of how to use the
GROUP_CONCAT()
function in MySQL:SQL
This will return the following result:
As you can see, the
GROUP_CONCAT()
function has returned all product names in a single row, separated by commas.