MySQL SELECT Statement
MySQL is used to retrieve SELECT statement data. This statement selects one or more columns from the database table and shows it to the user.
Whenever you need to see the data of any table in the database, you will always use the SELECT statement. Now let us try to know about the basic syntax of SELECT statement.
mysql > SELECT <options(* etc)>/<column_names> FROM table_name <options(WHERE id=1 etc)>
The syntax of SELECT statement is very simple. Firstly you do the SELECT statement define. After this you have 2 choices or you can define an option such as * (all) or you can define the names of the columns you want to show.
HOW TO SELECT ALL DATA
If you want to show the complete data of this table, you have to use * for it. An example of this is being given below.
mysql > select * from category;
When the above query is execute, all the rows of the category table are displayed.
HOW TO SELECT ONE COLUMN
If you want to show the data from a particular column, then you define the name of that column after the SELECT statement. After that FROM define the name of the clause and the table. An example of this is being given below.
mysql > select name from category;
All values of the name column of the category table will be displayed when the above query is executed.
HOW TO SELECT TWO OR MORE COLUMNS
To select more than one column, you separate the names of all the columns from the comma (,). This is explained below by example.
mysql > select name,status from category;
On the execution of the above statement, values of the name of the category table and the names of the status columns will be displayed.