Set Membership Search Explanation
Hi I have an SQL开发者_运维百科 question asking me to perform a query without set membership search...Can somebody explain to me what this is? and the alternatives ...
Quick & dirty:
Set membership behaves just like in math. You're looking for entities that exist in given a set.
SQL set membership can be done using IN operator. Set you are testing against can be static (SELECT * FROM table WHERE table.attr IN(1, 2 ,3)
) or result from subquery (just another query inside IN
section). When using subquery, a projection of subquery must be done on attribute you're comparing the results to. There is also a negation of membership, operator NOT IN
Alternatives? Well, it depends on a situation. Some can be done via JOIN
, but to fully answer your question, you should provide some more info.
精彩评论