Powered By Blogger

Sunday, November 27, 2011

SQL Basic Syntax

SELECT:
1. SELECT col1, col2, col3 FROM tablename 
2. SELECT DISTINCT col FROM tablename
3. SELECT COUNT(col) FROM tablename
4. SELECT col FROM tablename WHERE col = value
5. SELECT col FROM tablename WHERE col1 = value1 AND col2 = value2
6. SELECT col FROM tablename WHERE IN (value1 AND value2)
7. SELECT col FROM tablename WHERE BETWEEN (value1 AND value2)
8. SELECT col FROM tablename WHERE col LIKE '%value%'
9. SELECT col FROM tablename ORDER BY col

UPDATE:
1. UPDATE tablename SET col value2 WHERE col value1

DELETE:
1. DELETE tablename WHERE col = value

No comments:

Post a Comment