Where (SQL)
From Wikipedia, the free encyclopedia
A WHERE
statement in SQL specifies that a SQL command should only be run on rows that meet a specified condition. WHERE
statements are not typically required, but should be used if you only want a certain portion of your data to be affected by your SQL Statement.
The WHERE
statement has the following form:
COMMAND
FROM
table_nameWHERE
condition
Any rows meeting the WHERE condition will have the specified SQL command performed on it.
[edit] Examples:
Uses the DELETE
command to remove rows in mytable, if the value of mycol is greater than 100.
DELETE FROM mytable WHERE mycol > 100;
Without the WHERE
statement, it delete all rows from mytable:
DELETE FROM mytable;
Multiple conditions: Deletes rows in mytable if the value of mycol is greater than 100, and if item is less than specific
DELETE FROM mytable WHERE mycol > 100 AND item < specific;