---
title: "MySQL - Return all items in one row."  
description: "MySQL - Return all items in one row."  
author: "Revati S Misra"  
published: 2023-07-27  
updated: 2023-07-28  
canonical: https://www.mindstick.com/forum/159338/mysql-return-all-items-in-one-row  
category: "mysql"  
tags: ["mysql", "database table"]  
reading_time: 1 minute  

---

# MySQL - Return all items in one row.

[MySQL](https://www.mindstick.com/articles/12156/what-is-mysql) - Return all [items](https://www.mindstick.com/forum/33812/getting-number-of-items-selected-in-uicollectionview-in-ios) in one row.

## Replies

### Reply by Aryan Kumar

Sure, you can use the `GROUP_CONCAT()` function to return all items in a single row in MySQL. The syntax is as follows:

SQL

```plaintext
SELECT GROUP_CONCAT(column_name) AS column_name
FROM table_name;
```

For example, if you have a table called `products` with the columns `name` and `price`, you could use the following query to return all product names in a single row:

SQL

```plaintext
SELECT GROUP_CONCAT(name) AS names
FROM products;
```

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

```plaintext
CREATE TABLE products (
  id INT NOT NULL AUTO_INCREMENT,
  name VARCHAR(255) NOT NULL,
  price INT NOT NULL,
  PRIMARY KEY (id)
);

INSERT INTO products (name, price) VALUES
('Product 1', 100),
('Product 2', 200),
('Product 3', 300);

SELECT GROUP_CONCAT(name) AS names
FROM products;
```

This will return the following result:

```plaintext
names
Product 1,Product 2,Product 3
```

As you can see, the `GROUP_CONCAT()` function has returned all product names in a single row, separated by commas.


---

Original Source: https://www.mindstick.com/forum/159338/mysql-return-all-items-in-one-row

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
