Difference between revisions of "Delete Queries"

From TRCCompSci - AQA Computer Science
Jump to: navigation, search
Line 1: Line 1:
 
Used for deleting rows from a table.
 
Used for deleting rows from a table.
 +
<syntaxhighlight lang=sql>
 +
DELETE FROM table WHERE column1=value1;
 +
</syntaxhighlight>
  
DELETE FROM table WHERE column1=value1;
+
<syntaxhighlight lang=sql>
DELETE FROM table WHERE column1=value1 AND column2=value2;
+
DELETE FROM table WHERE column1=value1 AND column2=value2;
 +
</syntaxhighlight>
  
 
* Not specifying which records to delete will result in every record being deleted
 
* Not specifying which records to delete will result in every record being deleted

Revision as of 22:30, 21 December 2016

Used for deleting rows from a table.

DELETE FROM table WHERE column1=value1;
DELETE FROM table WHERE column1=value1 AND column2=value2;
  • Not specifying which records to delete will result in every record being deleted
  • The same can be achieved with 'DELETED * FROM table'
  • This process cannot be undone
  • Not to be confused with DROP, for deleting columns and tables.