What's the most efficient way to check if a record exists in Oracle?

前端 未结 10 1975
刺人心
刺人心 2020-12-23 03:10

A)

select decode(count(*), 0, \'N\', \'Y\') rec_exists
from (select \'X\'
      from dual
      where exists (select \'X\'
                    from sales
           


        
10条回答
  •  时光说笑
    2020-12-23 03:58

    SELECT 'Y' REC_EXISTS             
    FROM SALES                       
    WHERE SALES_TYPE = 'Accessories'
    

    The result will either be 'Y' or NULL. Simply test against 'Y'

提交回复
热议问题