DBAsupport.com Forums - Powered by vBulletin
Results 1 to 2 of 2

Thread: Query help

  1. #1
    Join Date
    Apr 2002
    Posts
    135

    Query help

    hi i have a table like this.

    A B

    1 2
    3 7
    6 4
    2 1
    7 3
    8 5

    I need the find the row which are like

    A B
    1 2
    2 1
    3 7
    7 3

    ie rows like a=b and b=a

    and in that i need any one pair not replica

    A B

    1 2
    3 7

    or else

    A B

    2 1
    7 3

    regards,
    deepa
    Good Judgement comes from Experience.
    Experience comes from Bad Judgement

  2. #2
    Join Date
    Apr 2001
    Location
    Czechia
    Posts
    712

    Re: Query help

    Hi!
    Originally posted by sona
    I need the find the row which are like

    A B
    1 2
    2 1
    3 7
    7 3

    ie rows like a=b and b=a
    Code:
    select T1.A, T1.B
      from T T1, T T2
     where T1.A = T2.B
       and T1.B = T2.A

    and in that i need any one pair not replica

    A B

    1 2
    3 7

    or else

    A B

    2 1
    7 3
    For example:
    Code:
    select T1.A, T1.B
      from T T1, T T2
     where T1.A = T2.B
       and T1.B = T2.A
       and T1.A < T1.B
    God bless the person who removed the <br> from the code tag!
    Ales
    The whole difference between a little boy and an adult man is the price of toys

Posting Permissions

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


Click Here to Expand Forum to Full Width