help with a very simple query

  • Dear All,

    I need a simple help i know its a very basic thing but i am stuck :hehe:

    I have two table (TABLE A) & (TABLE B) TABLE A is having a foreign key of TABLE B

    now i wanted to have records from table A which do not match or not exist in TABLE B

    please any 1 can reply me thanksss

  • Select ...

    from tableA A

    where not exists (select 1 from tableB B where B.FK = A.pk)

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me

  • Or, using a join instead...

    Select A.*

    from tableA A

    left join tableB B

    on A.PK = B.PK

    where B.PK is null

  • Thanks guys

    it was really nice & quick to have the replies it did work both of them worked fine also i learned if any 1 else can give few more ways then it will be good in learning different ways.

    THANKS ALOT PPL 🙂

Viewing 4 posts - 1 through 3 (of 3 total)

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