yklxmas Posted November 16, 2007 Share Posted November 16, 2007 Hello,I would like to know how to display multiple names of different places in one record in different column.For example:Table location (Location_Code, Location_Name)Location_Code | Location_NameGBLON | LONDONGBLIV | LIVERPOOLGBMNC | MANCHESTERTable location_link (Location_A, Location_:)Location_A | Location_BGBLON | GBLIVGBMNC | GBLONWhen comes to display data, I would like to display asLocation_A | Location_BLONDON | LIVERPOOLMANCHESTER | LONDONI've tried this sql but I know it's not the right one. Please help me. Please please!!! Many thanks in advanceSELECT b.Location_name as "Location 1", b.Location_name as "Location 2"FROM location_link as aINNER JOIN location as bON a.Location_A = b.Location_codeOR a.Location_B = b.Location_code Link to comment Share on other sites More sharing options...
Reg Edit Posted November 16, 2007 Share Posted November 16, 2007 Hello,I would like to know how to display multiple names of different places in one record in different column.For example:Table location (Location_Code, Location_Name)Location_Code | Location_NameGBLON | LONDONGBLIV | LIVERPOOLGBMNC | MANCHESTERTable location_link (Location_A, Location_:)Location_A | Location_BGBLON | GBLIVGBMNC | GBLONWhen comes to display data, I would like to display asLocation_A | Location_BLONDON | LIVERPOOLMANCHESTER | LONDONI've tried this sql but I know it's not the right one. Please help me. Please please!!! Many thanks in advanceSELECT b.Location_name as "Location 1", b.Location_name as "Location 2"FROM location_link as aINNER JOIN location as bON a.Location_A = b.Location_codeOR a.Location_B = b.Location_codeTry:SELECT b1.Location_name as "Location 1", b2.Location_name as "Location 2"FROM location_link as aINNER JOIN location as b1ON a.Location_A = b1.Location_codeINNER JOIN location as b2ON a.Location_B = b2.Location_code Link to comment Share on other sites More sharing options...
yklxmas Posted November 20, 2007 Author Share Posted November 20, 2007 Try:SELECT b1.Location_name as "Location 1", b2.Location_name as "Location 2"FROM location_link as aINNER JOIN location as b1ON a.Location_A = b1.Location_codeINNER JOIN location as b2ON a.Location_B = b2.Location_code Great stuff!!! It works. Finally solved something I had been trying to solve! Thanks! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.