• Teach Your Self With
             w3htmlschool.com

Mysql Select command

SELECT command is most commonly used for query data from table.
SELECT command retrieve rows and columns from the table in database.
SELECT command return the result in tabular form called RESULT SET.

Syntax


SELECT clauses used to show specific results
DISTINCT
FROM
WHERE
ORDER BY
LIMIT

[FROM] table_name
Table
+-------------+----------+
| Field | Type |
+-------------+----------+
| ID | int(11) |
| Name | char(35) |
| CountryCode | char(3) |
| District | char(20) |
| Population | int(11) |
+-------------+----------+
Example
mysql> use world;
Database changed
mysql> select * from city;
Output

+------------+------+-----------------------------------+------------
| ID | Name | CountryCode | Population |
+------+-----------------------------------+------------+------------+
| 1 | Kabul | AFG | 1780000 |
| 2 | Qandahar | AFG | 237500 |
| 3 | Herat | AFG | 186800 |
| 4 | Mazar-e-Sharif | AFG | 127800 |