SQL SELECT MULTIPLE

The SQL SELECT MULTIPLE statement is used to select multiple columns from a table. This allows you to retrieve data from more than one column in a single query, which is helpful when you need to analyze or display multiple fields at once.

This statement does not restrict you to a single column; instead, it lets you specify a list of columns separated by commas. You can select all columns from a table using the asterisk (*) symbol.

Syntax

The basic syntax for SELECT MULTIPLE is:


SELECT column1, column2, ...
FROM table_name;
        

Example

Consider the Orders table. We will select both Product and CustomerID from the table.

Code Example


-- Select product and customer ID from orders
SELECT Product, CustomerID FROM Orders;
            

Output

Laptop, 101 Phone, 105 Tablet, 103

Explanation

- The query retrieves both the Product and CustomerID columns from the Orders table.
- By specifying multiple columns in the SELECT statement, we retrieve data from both fields in one query.