select *
          from a t
         where exists (select 1
                  from a 
                 where t.b=2
                    or t.b = 3)
这个语句啥意思呀?
里面的查询查出来的都是1,外面的怎么可能有符合的呢?

解决方案 »

  1.   

    You use EXISTS to check for the existence of
    rows returned by a subquery. EXISTS is different from IN: EXISTS just checks for the existence
    of rows, whereas IN checks actual values. EXISTS typically offers better performance than IN
    with subqueries. Therefore, you should use EXISTS rather than IN whenever possible.The following good query rewrites the previous example to use EXISTS:
    -- GOOD (uses EXISTS rather than IN)
    SELECT product_id, name
    FROM products outer
    WHERE EXISTS
    (SELECT 1
    FROM purchases inner
    WHERE inner.product_id = outer.product_id);PRODUCT_ID NAME
    ---------- -----------------------------
    1 Modern Science
    2 Chemistry
    3 Supernova