Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2002
    Posts
    1

    Unanswered: Self Join Please Help!!!

    I have a problem with a self inner join query here it is.

    sql = "select * from table1 A inner Join table1 B on (a.pk = b.pk) where (A.field1 = value or B.field1 = value ) and (a.field2 <> b.field2 and a.field3 <> b.field3)

    my problem is I get nothing returned.

    I would like to know how to group the ands and ors , to make this thing work.

  2. #2
    Join Date
    Oct 2001
    Location
    England
    Posts
    426
    What are you trying to do?

    select *
    from table1 A
    inner Join table1 B
    on (a.pk = b.pk)
    where (A.field1 = value or B.field1 = value )
    and a.field2 <> b.field2
    and a.field3 <> b.field3


    This will return results if the fields fit the tests.
    note that is the fields ared null they will result in false for both = and <>.

Posting Permissions

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