1. Get rid of all advertisements and get unlimited access to documents by upgrading to Premium Membership. Upgrade to Premium Now and also get a Premium Badge!

Not exists nothig result

Discussion in 'SQL PL/SQL' started by Paul, Apr 4, 2014.

  1. Paul

    Paul Active Member

    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    55
    I have two tables
    tab1
    ID Name Cnt
    --- ---------- ------
    1 Первый 15
    2 Второй 10
    3 Первый 20
    4 Третий 7

    tab2
    ID
    ---
    0
    1
    2
    3
    4

    Cuz of what this query
    Code (Text):

    Select ID, 'True' as rez from tab2 t2 where not exists(select 2 from tab1 t1 where ID=2)
     
    Result is nothing? Though it have clause only for second column
     
  2. krasnoslobodtsev_si

    krasnoslobodtsev_si Forum Genius

    Messages:
    626
    Likes Received:
    129
    Trophy Points:
    810
    Location:
    Russian Federation
    Your sql-query doesn't give out result because:

    For comparing....

    Code (SQL):


    WITH
    tab1 AS
    (
    SELECT 1 ID, 'Первый' Name  ,15 Cnt FROM dual UNION ALL
    SELECT 2 ,'Второй', 10 FROM dual UNION ALL
    SELECT 3 ,'Первый', 20 FROM dual UNION ALL
    SELECT 4 ,'Третий' ,7 FROM dual
    )
    SELECT * FROM TABLE(sys.odcinumberlist(0,1,2,3,4)) t2
    WHERE NOT EXISTS (SELECT 2 FROM tab1 WHERE id = t2.column_value ) ;

     
     
    Paul likes this.