Update data with new value
UPDATE tablename SET fieldname1 = values, fieldname2 = values WHERE condition
Update data with value in another table
UPDATE tablename1 SET tablename1.fieldname=tablename2.fieldname FROM tablename2 WHERE condition
Showing posts with label SQL. Show all posts
Showing posts with label SQL. Show all posts
Wednesday, May 18, 2011
Thursday, May 12, 2011
SQL Statement - SELECT
Select data from 1 table
SELECT * FROM TableNames
Select data from 2 or more tables
SELECT table1.*, table2.* FROM table1,table2 WHERE table1.field1=table2.field1
Append 2 tables
SELECT * FROM table1
UNION
SELECT * FROM table2
Select data which is not exists in another table
SELECT * FROM table1 WHERE NOT EXISTS (SELECT * FROM table2 WHERE table1.field1=table2.field1)
SELECT * FROM TableNames
Select data from 2 or more tables
SELECT table1.*, table2.* FROM table1,table2 WHERE table1.field1=table2.field1
Append 2 tables
SELECT * FROM table1
UNION
SELECT * FROM table2
Select data which is not exists in another table
SELECT * FROM table1 WHERE NOT EXISTS (SELECT * FROM table2 WHERE table1.field1=table2.field1)
Subscribe to:
Posts (Atom)