Learning notes for MySQL required: 1 # select a database
USE mysql
# Back to the list of available databases
SHOW DATABASES
# Return the available tables in the current database
SHOW TABLES
# Return table columns
Show columns from db
# Display creation statements for a specific database
Show create database mysql
# Display a wide range of server status information
SHOW STATUS
# Display the security permissions of authorized users
SHOW GRANTS
Multiple SQL statements must be separated by semicolons.
SQL statements are case-insensitive and often capitalized.
Use DISTINCT to retrieve different rows. only different values are returned.
LIMIT result, LIMIT clause
LIMIT 5 returns no more than five rows.
LIMIT 3 and 4 rows starting from row 3
LIMIT 4 OFFSET 3 (the result is the same as above) [supported after MySQL5]
Order by clause sorting
DESC/ASC specify the sorting direction
WHERE clause. order by is located after WHERE.
Operator |
Description |
= |
Equal |
<> |
Not equal |
! = |
Not equal |
< |
Less |
<= |
Less than or equal |
> |
Greater |
> = |
Greater than or equal |
BETWEEN |
Between two specified values |
NULL
WHERE *** is null check whether the field has a NULL value.
And or operator.
The IN operator is used to specify the condition range. multiple valid values are separated by commas.
NOT negative operator, which can be used to reverse the IN, BETWEEN, and EXISTS clauses.