Jump to content

Try to display different town names in the same record


yklxmas

Recommended Posts

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

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
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

Link to comment
Share on other sites

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...