Select Statement
SELECT 'column_name' FROM 'table_name'
Distinct
SELECT DISTINCT 'column_name'
FROM 'table_name'
Where
SELECT 'column_name'
FROM 'table_name'
WHERE 'condition'
In
SELECT 'column_name'
FROM 'table_name'
WHERE 'condition'
Between
SELECT 'column_name'
FROM 'table_name'
WHERE 'column_name' BETWEEN 'value1'
AND 'value2'
Like
SELECT 'column_name'
FROM 'table_name'
WHERE 'column_name' LIKE {PATTERN}
Order By
SELECT 'column_name'
FROM 'table_name'
[WHERE 'condition']
ORDER BY 'column_name' [ASC, DESC]
Count
SELECT COUNT ('column_name')
FROM 'table_name'
Group By
SELECT 'column_name1',
SUM('column_name2')
FROM 'table_name'
GROUP BY 'column_name1'
Having
SELECT 'column_name1',
SUM('column_name2')
FROM 'table_name'
GROUP BY 'column_name1'
HAVING (arithmetic function condition)
Create Table Statement
CREATE TABLE 'table_name'
('column1' 'data_type_for_column_1',
'column2' 'data_type_for_column_2', ...)
Drop Table Statement
DROP TABLE 'table_name'
Truncate Table Statement
TRUNCATE TABLE 'table_name'
Insert Into Statement
INSERT INTO 'table_name' ('column1',
'column2', ...)
VALUES('value1', 'value2', ...)
Insert Into Select Statement
INSERT INTO 'table1' ('column1','column2',...)
SELECT 'column3', 'column4', ...
FROM 'table2'
Update Statement
UPDATE 'table_name'
SET 'column1' = [new value]
WHERE {condition}
Delete From Statement
DELETE FROM 'table_name'
WHERE {condition}
No comments:
Post a Comment