Jump to Navigation

057 - SQL Quick Reference

SQL Condition Clauses:

field = value
field > value
field >= value
filed != value (field is not equal to value)
field <> value (field is not equal to value)
field BETWEEN value1 and value2
field LIKE value
field NOT LIKE vale
field is NULL
field IN (value1, value2, value3, value4)
field NOT IN (value1, value2, value3)

Selecting from Multiple table:

SELECT table1.field, table2.filed FROM table1, table2 WHERE
table1.field = table2.filed;

or

SELECT table1filed, table2filed FROM table1, LEFT JOIN table2 ON
table1.table1filed = table2.table2filed;

Sorting the Result:

SELECT * FROM tablename WHERE field=value1 ORDER BY field2 ASC|DESC;

Limiting the Result:

SELECT * FROM tablename WHERE field1=value1
ORDER BY field2 ASC
LIMIT offset, number_of_rows_to_be_returned;

 

MySQL:


Main menu 2

Story | by Dr. Radut