In or exists operator

  • Hi,

    I want to know that how to use Exists operator instead for below query

    ...

    "select fname,lname,minit,job_lvl,job_id from employee where job_id in (1,2)"

    Sunil....

  • su_kumar11 (8/4/2008)


    Hi,

    I want to know that how to use Exists operator instead for below query

    ...

    "select fname,lname,minit,job_lvl,job_id from employee where job_id in (1,2)"

    Sunil....

    I don't see how this would be useful...

    I would never use EXISTS for a static list of constants. EXISTS is useful when you have to check some conditions between two or more tables.

    Anyway you could write something like:

    select fname,lname,minit,job_lvl,job_id

    from employee as a

    where exists (

    select 1

    from employee as b

    where a.job_id = b.job_id

    and b.job_id between 1 and 2

    )

    ... but I think this is nonsense!!

    Regards,

    Gianluca

    -- Gianluca Sartori

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply