Probs In Query

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sonia.sardana
    New Member
    • Jul 2006
    • 95

    Probs In Query

    TABLE FIRST
    Create table student1(roll int,marks int)
    insert into student1 values(1,10)
    insert into student1 values(2,20)
    insert into student1 values(3,30)


    TABLE SECOND
    create table info(roll int,addr varchar(10))
    insert into info values(1,'Delhi ')
    insert into info values(2,'Fbd')
    insert into info values(4,'Gurga on')


    1)select info.roll from info ,student1 where info.roll=stude nt1.roll
    ANSWER IS RIGHT
    1
    2

    2)select info.roll from info ,student1 where info.roll <> student1.roll
    ANSWER is supposed to be Only Roll No 4.
    But the result is coming out Different......
  • ck9663
    Recognized Expert Specialist
    • Jun 2007
    • 2878

    #2
    Originally posted by sonia.sardana
    TABLE FIRST
    Create table student1(roll int,marks int)
    insert into student1 values(1,10)
    insert into student1 values(2,20)
    insert into student1 values(3,30)


    TABLE SECOND
    create table info(roll int,addr varchar(10))
    insert into info values(1,'Delhi ')
    insert into info values(2,'Fbd')
    insert into info values(4,'Gurga on')


    1)select info.roll from info ,student1 where info.roll=stude nt1.roll
    ANSWER IS RIGHT
    1
    2

    2)select info.roll from info ,student1 where info.roll <> student1.roll
    ANSWER is supposed to be Only Roll No 4.
    But the result is coming out Different......
    Try WHERE NOT EXISTS or WHERE NOT IN

    -- CK

    Comment

    Working...