Results 1 to 3 of 3

Thread: self-join help

  1. #1
    Join Date
    Jan 2004
    Posts
    19

    Unanswered: self-join help

    I have a SCHOOL table with the following rows:

    ID CLASS CLASSID
    -----------------------
    100 BIO 000020
    100 ART 000040

    I need my info to display like:
    BIO, ART
    but the code I have displays two rows like:
    BIO, ART
    ART,BIO

    How can I get rid of one of the rows?

    Here is the code I created:

    select a.CLASS + ',' + b.CLASS as SCHEDULE
    from SCHOOL a, SCHOOL b
    where a.id = b.id
    and a.CLASS != b.CLASS
    tfil

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    nice try, you were so close!!

    change your query to this:
    Code:
    select a.CLASS + ',' + b.CLASS as SCHEDULE
      from SCHOOL a
         , SCHOOL b
     where a.id = b.id
       and a.CLASS > b.CLASS
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Jan 2004
    Posts
    19

    self-join help

    I can't tell you how silly I feel !!! THANK YOU SO MUCH!!
    tfil

Posting Permissions

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