The most commonly used command in mysql is SELECT statement. It is used to retrieve the selected data according to the conditions specified. In simple words, we can say that the select statement used to query or retrieve data from a table in the database. Here is the syntax of select statement.
SELECT expressions FROM tables WHERE conditions;
There are some optional clause in the Select statement, they are define as follows:
Here i have shown some examples of the Select statement.
i have use a table name studinfo From the database school whose view as given below:
basic Select Query is given below
SELECT * //'*' uses to show all value FROM studinfo; //studinfo is a tablename
After execute this query we got the result as image given below
Note: use asterisk (*) to display all the data from a selected table
Now if we want some selected columns like fname and lname so we can use the below code
SELECT sid, fname, lname //select fname and lname FROM studinfo; //studinfo ia a tablename
use another condition where full syntax of Select can be use
SELECT * //show all the value FROM studinfo //studinfo is tablename WHERE sid > 106; //conditions given here> 0
use some optional clause in the select statement
SELECT * //show all the value FROM studinfo //studinfo is tablename ORDER BY fname; //order condistion write here
SELECT fname //show only fname AS Name //show heading as column Name FROM studinfo; //studinfo is tablename
In the above code AS can be use to given output columnname, like Name.
(追記) (追記ここまで)Others
Languages
Frameworks
Web / Design
Mobile Technology
Sql & Technology
R4R