locked
How to filter data in two tables RRS feed

  • Question

  • hi I have two tables TableA and TableB of data with common coloumns name fkcolumnb and pkcoloumna in two tables

    how to retrive data which are not present in TableA?

     

     

    thanks in advance


    satwick
    Thursday, November 10, 2011 9:35 PM

Answers

  • Select * From TableB Where Not Exists (Select 1 From TableA Where TableA.PKColumnA = TableB.FKColumnB)
    Best Wishes, Arbi --- MCC 2011; Please vote if you find this posting was helpful or Mark it as answered.
    • Edited by Arbi Baghdanian Thursday, November 10, 2011 9:38 PM
    • Proposed as answer by Naomi N Thursday, November 10, 2011 9:41 PM
    • Marked as answer by satwick Thursday, November 10, 2011 9:43 PM
    Thursday, November 10, 2011 9:36 PM

All replies

  • Select * From TableB Where Not Exists (Select 1 From TableA Where TableA.PKColumnA = TableB.FKColumnB)
    Best Wishes, Arbi --- MCC 2011; Please vote if you find this posting was helpful or Mark it as answered.
    • Edited by Arbi Baghdanian Thursday, November 10, 2011 9:38 PM
    • Proposed as answer by Naomi N Thursday, November 10, 2011 9:41 PM
    • Marked as answer by satwick Thursday, November 10, 2011 9:43 PM
    Thursday, November 10, 2011 9:36 PM
  • Hi, try please :

    Select

    B.* From TableB B

    left

    join TableA A on A.PKColumnA = B.FKColumnB

    Where A.PKColumnA is NULL

     

     


    Best regards
    • Edited by Badii Gharbi Thursday, November 10, 2011 9:42 PM
    Thursday, November 10, 2011 9:40 PM