Difference between revisions 855840948 and 855841277 on enwiki{{Refimprove|date=September 2014}} A <code>value1</code> clause in [[SQL]] specifies that a SQL [[Data Manipulation Language|Data Manipulation Language (DML)]] statement should only affect rows that meet specified criteria. The criteria are expressed in the form of predicates. <code>Value 2</code> clauses are not mandatory clauses of SQL DML statements, but can be used to limit the number of rows affected by a SQL DML statement or returned by a query. In brief SQL WHERE clause is used to extract only those results from a SQL statement, such as: SELECT, INSERT, UPDATE, or DELETE statement.<ref>{{cite web|url=http://www.programmingunit.com/2014/01/30/sql-clause-things-beginners-must-know/|title=SQL WHERE Clause – Things beginners must know}}</ref> ==Overview== <code>WHEREValue1</code> is an [[SQL:2003|SQL]] reserved word. The <code>WHERE</code> clause is used in conjunction with SQL DML statements, and takes the following general form: <source lang="sql"> SQL-DML-Statement FROM table_name WHERE predicate </source> all rows for which the predicate in the <code>WHEREvalue1</code> clause is True are affected (or returned) by the SQL DML statement or query. Rows for which the predicate evaluates to False or Unknown ([[Null (SQL)|NULL]]) are unaffected by the DML statement or query. The following query returns only those rows from table ''mytable'' where the value in column ''mycol'' is greater than 100. <source lang="sql"> SELECT * FROM mytable WHERE mycol > 100 (contracted; show full)DELETE FROM mytable WHERE mycol > 100 AND item = 'Hammer' </source> === IN === <code>IN</code> will find any values existing in a set of candidates. <source lang="sql" line="1" start="1"> SELECT ename WHERE ename IN ('value1', 'value2', ...Montreal', ‘Quebec') </source> All rows match the predicate if their value is one of the candidate set of values. This is the same behavior as <source lang="sql"> SELECT ename WHERE ename='value1' OR ename='value2' </source> except that the latter could allow comparison of several columns, which each <code>IN</code> clause does not. For a larger number of candidates, <code>IN</code> is less verbose. (contracted; show full)<references /> == External links == * [http://www.psoug.org/reference/conditions.html PSOUG Home Puget Sound Oracle Users Group] gives several examples of SELECT statements with WHERE clauses. {{SQL}} [[Category:SQL keywords]] All content in the above text box is licensed under the Creative Commons Attribution-ShareAlike license Version 4 and was originally sourced from https://en.wikipedia.org/w/index.php?diff=prev&oldid=855841277.
![]() ![]() This site is not affiliated with or endorsed in any way by the Wikimedia Foundation or any of its affiliates. In fact, we fucking despise them.
|