MySQL SQL Syntax
 
Select statement
 
Data is extracted from the table using the SELECT SQL command.
 
Here is the format of a SELECT statement:
 
SELECT column_names from table_name [WHERE ...conditions];
 
The conditions part of the statement is optional (we'll go through this later). Basically, you require to know the column names and the table name from which to extract the data. For example, in order to extract the first and last names of all employees, issue the following command.
 
SELECT f_name, l_name from employee_data;
 
The statement tells MySQL to list all the rows from columns f_name and l_name.
 
mysql> SELECT f_name, l_name from employee_data;
 
On close examination, you'll find that the display is in the order in which the data was inserted. Furthermore, the last line indicates the number of rows our table has.
To display the entire table, we can either enter all the column names or use a simpler form of the SELECT statement.
 
SELECT * from employee_data;
 
Some of you might recognize the * in the above statement as the wildcard. Though we don't use that term for the character here, it serves a very similar function. The * means 'ALL columns'. Thus, the above statement lists all the rows of all columns.