SQL Select – Retrieve data from a Table

SQL Select table example – Learn how to retrieve data from a table in MySQL database with example and important points.

Select statement used to retrieve records from one or more database tables.The result is stored in the result table called result set.

SQL syntax to retrieve the data from multiple columns from tables.

SELECT [hint][DISTINCT] [select_list]
FROM [table_list]
[WHERE conditions]
[GROUP BY group_by_list]
[HAVING search_conditions]
[ORDER BY order_list [ASC DESC] ]
[FOR UPDATE for_update_options]

SQL Select – Retrieve data from Multiple Columns

SQL query to retrieve all the columns from the table.

query example:

Select  *  from books;

in the above example * is a wild card  which means  “all columns”;

ISBN_NOTITLEAUTHORFIRSTNAMEAUTHORLASTNAME
181The CastleFranzKalka
191Animal FarmGeorgeOrwell
205MadhushalaHarivanshRai
209HistoricaHerodotusHerodotus

SQL Select – Retrieve data from Single Column

SQL query to retrieve the data from single column from the table. We will retrieve data from TITLE column from a BOOKS table.

   Example query:   select TITLE from BOOKS;

TITLE
The Castle
Animal Farm
Madhushala
Historica

NOTES:

  1. Using select statement we can retrieve data with multiple columns by specifying column names.
  2. From key word used to indicate from which database tables the data is taken.
  3. Where key word used to identify which rows to be retrieved.
  4. Group by groups rows to apply aggregate functions to each group.
  5. Having is applied on the results of group by and can use agree gate functions.
  6. Order by specifies an order in which to return the rows.
SQL Select – Retrieve data from a Table

Scroll to top