List of 41 MySQL queries
- SELECT * FROM
table_name
; - SELECT
column_name
FROMtable_name
; - SELECT COUNT(*) FROM
table_name
; - SELECT MAX(
column_name
) FROMtable_name
; - SELECT MIN(
column_name
) FROMtable_name
; - SELECT AVG(
column_name
) FROMtable_name
; - SELECT SUM(
column_name
) FROMtable_name
; - SELECT DISTINCT
column_name
FROMtable_name
; - SELECT
column_name
FROMtable_name
WHEREcolumn_name
= 'value'; - SELECT
column_name
FROMtable_name
WHEREcolumn_name
LIKE '%value%'; - SELECT
column_name
FROMtable_name
WHEREcolumn_name
BETWEEN 'value1' AND 'value2'; - SELECT
column_name
FROMtable_name
ORDER BYcolumn_name
ASC; - SELECT
column_name
FROMtable_name
ORDER BYcolumn_name
DESC; - SELECT
column_name
FROMtable_name
LIMIT 10; - SELECT
column_name
FROMtable_name
LIMIT 10 OFFSET 5; - SELECT
column_name
FROMtable_name
WHEREcolumn_name
IN ('value1', 'value2', 'value3'); - SELECT
column_name
FROMtable_name
WHEREcolumn_name
NOT IN ('value1', 'value2', 'value3'); - SELECT
column_name
FROMtable_name
WHEREcolumn_name
IS NULL; - SELECT
column_name
FROMtable_name
WHEREcolumn_name
IS NOT NULL; - SELECT
column_name
FROMtable_name
GROUP BYcolumn_name
; - SELECT
column_name
, COUNT(*) FROMtable_name
GROUP BYcolumn_name
; - SELECT
column_name
, AVG(column_name
) FROMtable_name
GROUP BYcolumn_name
; - SELECT
column_name
, SUM(column_name
) FROMtable_name
GROUP BYcolumn_name
; - SELECT
column_name
FROMtable_name
HAVING COUNT(*) > 10; - SELECT
column_name
FROMtable_name
WHEREcolumn_name
IN (SELECTcolumn_name
FROMtable_name2
); - SELECT
column_name
FROMtable_name
LEFT JOINtable_name2
ONtable_name
.column_name
=table_name2
.column_name
; - SELECT
column_name
FROMtable_name
RIGHT JOINtable_name2
ONtable_name
.column_name
=table_name2
.column_name
; - SELECT
column_name
FROMtable_name
INNER JOINtable_name2
ONtable_name
.column_name
=table_name2
.column_name
; - INSERT INTO
table_name
(column_name
,column_name2
) VALUES ('value1', 'value2'); - UPDATE
table_name
SETcolumn_name
= 'value1' WHEREcolumn_name
= 'value2'; - DELETE FROM
table_name
WHEREcolumn_name
= 'value1'; - CREATE TABLE
table_name
(column_name
VARCHAR(255),column_name2
INT); - DROP TABLE
table_name
; - ALTER TABLE
table_name
ADDcolumn_name
VARCHAR(255); - ALTER TABLE
table_name
DROPcolumn_name
; - RENAME TABLE
table_name
TOnew_table_name
; - SHOW TABLES;
- SHOW COLUMNS FROM
table_name
; - SHOW CREATE TABLE
table_name
; - EXPLAIN SELECT * FROM
table_name
; - USE
database_name
; 4
No comments:
Post a Comment