Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2002
    Posts
    4

    Unanswered: sql query solution

    Hi guys,

    I need to be able to check if rows in table Input are there in table Transform and if they are not present in table Transform ,then I need to see those rows in Input not present in Transform.
    the primary keys in input are st1,st2,st3.
    the primary keys in transform are jt1,jt2,jt3.

    I am checking to see if st1=jt1 and st2=jt2 to see if rows in input match to rows in transform.
    could you guys give me some sample code for this.

    Thanks

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    sounds like you want a left outer join, returning only those rows that do not have a match
    Code:
    select st1,st2,st3
      from Input
    left outer
      join Transform
        on st1=jt1 and st2=jt2 
     where jt1 is null
       and jt2 is null
    on the other hand, if you want all rows of Input, whether or not they have a match, then add jt3 to the SELECT list and drop the WHERE clause

    rudy
    http://rudy.ca/

  3. #3
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1

    Re: sql query solution

    This will show the rows in Input that are not in Transform:

    SELECT st1, st2, st3 FROM Input
    MINUS
    SELECT jt1, jt2, jt3 FROM Transform

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •