MySQL simple syntax (3)

delete data

Truncate table to delete data
- Features: You can not add where keyword, delete the data equivalent to the entire table
- syntax: TRUNCATE TABLE table_name
- example: TRUNCATE TABLE games
using the delete command to delete data
- Features: You can add keywords where you can delete data specified in the table
- syntax: DELETE [FROM] the WHERE condition_expression the table_name
- example: DELETE FROM games the WHERE GNO = 3
- note that some versions of MySQL do not think adding FROM keyword is wrong.

Queries basis of simple queries

All lookup table rows and columns
- Syntax: SELECT col1_name , col2_name, col2_name ...... the FROM table_name * the FROM table_name or the SELECT
- example: SELECT * the FROM games
- example: SELECT GNO, GType FROM games
part of the column of the query tables
- Syntax: SELECT col1_name, col2_name the FROM table_name
- features: Add the field names in the table we want to query later in the SELECT
- example: SELECT GNO, GType FROM games
aliases use
- syntax: SELECT col1_name AS 'Name1', col2_name AS 'Name2' FROM table_name
- Note: AS keyword can be omitted
- an example: SELECT gName AS 'ID' FROM games
- examples: SELECT GNO 'sequence' FROM games
eliminate duplicate rows of the result set
- syntax: the DISTINCT the SELECT col_name the FROM table_name
- example: SELECT DISTINCT gName FROM games
specified display range data of the result set
- Grammar: the SELECT * the FROM LIMIT number1, number2
- Note: The results of the first data set default is 0, number1 represents the number + 1 from the first row to start the query, number2 represents the total number of data queries; only one back if LIMIT keyword number, then the default start row data from a first query, a query empty the n
- examples: the SELECT * the fROM 2,2 & games the LIMIT
- example: SELECT * fROM games LIMIT 2

Published 37 original articles · won praise 10 · views 10000 +

Guess you like

Origin blog.csdn.net/OneLinee/article/details/78734616