|
|
Action Queries
Related Content:
[edit] Basic Examples
[edit] Delete Queries
SQL DELETE * FROM tablename WHERE criteria ANSI Standard Syntax SQL DELETE Field1, Field2 FROM tablename WHERE criteria You can delete all the data from a given table by supplying all (*) fields and no criteria. This is useful for temporary tables: SQL DELETE * FROM tablename Note that the non-standard syntax allow you to join several tables and therefore specify which rows of single table to be deleted. Only one table's content can be deleted per a delete query: SQL DELETE o.* FROM tblOrders AS o INNER JOIN tblCustomers AS c WHERE c.Inactive <> 0;
The query will delete all orders for inactive customers but will not delete the data about those inactive customers. To achieve similar objective using standard syntax, which does not allow joining on a delete query, would be: SQL DELETE FROM tblOrders
WHERE EXISTS ( SELECT NULL FROM tblCustomers WHERE Inactive <> 0 AND CustomerID = tblOrders.CustomerID ); [edit] Append Queries
SQL INSERT INTO Tablename (Field1, Field2) VALUES (Value1, Value2)
[edit] Update Queries
SQL UPDATE Tablename SET Field1=Value1, Field2=Value2 WHERE criteria
[edit] Make Table Queries
SQL SELECT Tablename.Field1, Tablename.Field2, Tablename.Field3 INTO Newtable
FROM Tablename; [edit] Calling Methods
|
| This page was last modified 15:45, 21 April 2012. This page has been accessed 1,851 times. Disclaimers |