Editor settings

General settings

Save settings

SQL for beginners

Select multiple columns #

Now that we know how to select one column from a table, here's the syntax to select multiple columns:

SELECT column1, column2 FROM table;
  • column1, column2: Specify the columns you want to retrieve, separated by a comma ,, or use * to select all columns. Notice that there is no comma after the last column.
  • table: Specifies the table from which to retrieve the data.

Exercise #

We have already created a table customers with the columns first_name, last_name, age, and gender. Write a command to retrieve data from customers table with all columns.

Tests #

  • The result has first_name column.
  • The result has last_name column.
  • The result has age column.
  • The result has gender column.
Solution
SELECT * FROM customers;
SELECT first_name, last_name, age, gender FROM customers;
Output will be displayed here