What is the difference between any and all in sql
The following SQL statement will display records from "EmpInfo" table and It compares a value from main table to each value in a list or results from a subquery and evaluates to true if any of the subquery values meet the condition.
The sub-query returns 5 and 6. Then main query is compared with this, if any of the ages in table is greater than any of the values of sub-query i. The ANY and ALL operators allow you to perform a comparison between a single column value and a range of other values. ANY means that the condition will be true if the operation is true for any of the values in the range.
ALL means that the condition will be true only if the operation is true for all values in the range. Below is a selection from the "Products" table in the Northwind sample database:. We just launched W3Schools videos. Active 8 months ago. Viewed 66k times. Improve this question. Nikita Fedyashev Jagan Jagan 4, 17 17 gold badges 56 56 silver badges 70 70 bronze badges. Add a comment. Active Oldest Votes. Improve this answer. Pranay Rana Pranay Rana k 34 34 gold badges silver badges bronze badges.
I mean is it a pure matter of taste, or are there special cases where they act differently? I tried with some null values and empty sets but have not found a difference. But should you ever be in need of that odd construction, then " Tejas Patel Tejas Patel 3 3 gold badges 9 9 silver badges 17 17 bronze badges. Wernfried Domscheit Wernfried Domscheit This is the simpler and better answer IMO — y o.
Mansi Raval Mansi Raval 4 4 silver badges 10 10 bronze badges. But be aware that they act quite oddly on empty sets Try e.
0コメント