Tuesday, February 7, 2012

SELECT statements

Select statements for all kinds of SQL are pretty the same.The words that are italic should be replaced with required values.

SELECT field names
FROM table name
WHERE condition
GROUP BY field namesclause groups rows sharing a property
HAVING field names
ORDER BY field names ASC/DESC


Lets take a look at examples:
TABLE1:
Name | ID
---------------
John | 1
Dorothe | 2
Lindsay | 7
Peter | 4

SELECT field names
FROM table name
WHERE condition
GROUP BY field namesclause groups rows sharing a property
HAVING field names
ORDER BY field names ASC/DESC