Press "Enter" to skip to content

mysqlselect

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 structure Used for Example explanation

+————-+———-+
| Field | Type |
+————-+———-+
| ID | int(11) |
| Name | char(35) |
| CountryCode | char(3) |
| District | char(20) |
| Population | int(11) |
+————-+———-+

Example for Mysql Select command

mysql> use world;
Database changed
mysql> select * from city;

Output of Above Example

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