Basic Statement

list up useful statements, just find the statement you need with ctrl+f

Reference: https://www.w3schools.com/sql/default.asp

This statement is for MySQL Syntax.

Select sub columns from the table

SELECT col1, col2
FROM table_name;

Select all columns from the table (* means all)

SELECT * FROM table_name;

Select sub columns who have distanct values

SELECT DISTINCT col1, col2
FROM table_name;

Filter records based on a condition

SELECT col1, col2
FROM table_name
WHERE condition;

Operator: =, >, <, >=, <=, <>, BETWEEN, LIKE(To find a pattern), IN(Multple values)

Connect several conditions with logical operator: AND, OR, NOT

Sort the table based on the col

Insert new records into a table

Check for NULL

Update for modifying the existing records

Under this condition, we modify the value from col1 with new value, so basically update statment is for changing the value in column.

Delete some records(row records)

Select top n data

You can use more function like min, max, count, avg, and sum

Find the data which of column matches specific string pattern with regex.

Aliases for giving name to table or column

(Because this statement is just temporary, so an alias only exists for the duration of that query.)

Last updated

Was this helpful?