IN,ANY And ALL
IN ANY And ALL are Keyword-Operator, Which is Used In WHERE Clause of SQL Statements.
IN,ANY And ALL Returns Multiple Raw As per conditions.
USE OF IN in SQL Statments:
- SELECT * FROM tablename WHERE columnname IN ('value1','value2','value3','value4')
- SELECT * FROM tablename WHERE columnname IN (SELECT columnname FROM tablename WHERE Conditions..)
- SELECT * FROM tablename WHERE (col1,col2) IN (('val1','val2'),('val11','val22'))
- SELECT * FROM tablename WHERE (col1,col2) IN (SELECT col1,col2 FROM table WHERE Conditions..)
USE OF ANY and ALL in SQL Statments:
- Used with a WHERE or HAVING clause.
- The ANY operator returns true if any of the subquery values meet the condition.
- The ALL operator returns true if all of the subquery values meet the condition.
ANY Syntax
SELECT column_name(s)
FROM table_name
WHERE
column_name operator ANY
(SELECT column_name FROM table_name WHERE
condition);
ALL Syntax
SELECT column_name(s)
FROM table_name
WHERE
column_name operator ALL
(SELECT column_name FROM table_name WHERE condition);
The operator must be a standard comparison
operator (=, <>, !=, >, >=, <, or <=).
Comments
Post a Comment