The only way to retrieve data from a MySQL column is to use the SELECT statement. This is also one of the most often used statements in MySQL.

In broader terms, the SELECT statement is a DML (Data Manipulation Language) statement. DML statements are commands that allow you to retrieve and manipulate data in the database.

In addition to the SELECT statement we frequently use the FROM clause that specifies which table or tables data will be pulled from.

Syntax

SELECT Column_name1, Column_name2, ... FROM Table_Name

Selecting All Columns

To select all columns, we have to do this:

SELECT * FROM Table_name

In the example above we see that the '*' (asterisk) character replaces all possible value and it literally means 'find all'.

Selecting Specific Columns

To select only certain columns, we have to do this:

SELECT Column_name1, Column_name2 FROM Table_name WHERE condition_name;

Examples

Display all records from Employee table:

SELECT * FROM Emp;

Display Department Number, Employee Number, Job from Employee table:

SELECT DeptNo, EmpNo, Job FROM Emp;

Display Department Number, Employee Number, Job, Salary from Employee table Table:

SELECT DeptNo, EmpNo, Job, Sal FROM Emp;

Show employees information whose Salary is greater than 2000:

SELECT * FROM Emp WHERE Sal>2000;