Blog of a Filipino Developer about C#, VB.NET, ASP.NET, Java, PHP, SQL Server, MySql and Oracle RSS 2.0
 Friday, March 11, 2005

I have been playing around with alot of SQL queries lately... with that, i have decided to compile a useful cue card to show basic keywords in SQL. I then went on to seach for websites that has an existing sql cue card and finally found one here. 

Here is the summary of the content of that site. You can also click the keyword to get a more detailed information about that keyword.

Select 
SELECT "column_name" FROM "table_name"

Distinct 
SELECT DISTINCT "column_name"
FROM "table_name"

Where 
SELECT "column_name"
FROM "table_name"
WHERE "condition"

And/Or 
SELECT "column_name"
FROM "table_name"
WHERE "simple condition"
{[AND|OR] "simple condition"}+

In
SELECT "column_name"
FROM "table_name"
WHERE "column_name" IN ('value1', 'value2', ...)

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 (arithematic function condition)

Create Table
CREATE TABLE "table_name"
("column 1" "data_type_for_column_1",
"column 2" "data_type_for_column_2",... )

Drop Table
DROP TABLE "table_name"

Truncate Table 
TRUNCATE TABLE "table_name"

Insert Into 
INSERT INTO "table_name" ("column1", "column2", ...)
VALUES ("value1", "value2", ...)

Update
UPDATE "table_name"
SET "column_1" = [new value]
WHERE {condition}

Delete From
DELETE FROM "table_name"
WHERE {condition}

Friday, March 11, 2005 11:07:41 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
SQL
Comments are closed.
On this page
Archive
<October 2008>
SunMonTueWedThuFriSat
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2008
Keith Rull
Sign In
Statistics
Total Posts: 254
This Year: 51
This Month: 0
This Week: 0
Comments: 111
Themes
Pick a theme:
Ads
All Content © 2008, Keith Rull
DasBlog theme 'Business' created by Christoph De Baene (delarou)