If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > self-join help

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-19-04, 12:26
liftapia liftapia is offline
Registered User
 
Join Date: Jan 2004
Posts: 19
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
Reply With Quote
  #2 (permalink)  
Old 10-19-04, 15:00
r937 r937 is online now
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
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
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 10-19-04, 16:16
liftapia liftapia is offline
Registered User
 
Join Date: Jan 2004
Posts: 19
self-join help

I can't tell you how silly I feel !!! THANK YOU SO MUCH!!
__________________
tfil
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On