ToonMariner Posted November 20, 2009 Share Posted November 20, 2009 HI peeps... I have a table of journeys storing the id of starting location and end location. I would like one query that would return both location names as specified (i.e. start and end) Something like... SELECT `location`.`name` AS `start` , `location`.`name` AS `end` FROM `journeys` LEFT JOIN `journeys` ON `journeys`.`start_id` = `location`.`location_id` LEFT JOIN `journeys` ON `journeys`.`end_id` = `location`.`location_id` WHERE `journey_id` = SPECIFIED_ID any tips much appreciated Quote Link to comment https://forums.phpfreaks.com/topic/182294-simple-i-bet-but-i-still-need-a-bit-of-guidance/ Share on other sites More sharing options...
JustLikeIcarus Posted November 20, 2009 Share Posted November 20, 2009 Heres one way to do it. select location_s.start as start, location_e.name as end from journeys, location as location_s, location as location_e where journeys.start_id = location_s.location_id and journeys.end_id = location_e.location_id and journeys.journey_id = ? Quote Link to comment https://forums.phpfreaks.com/topic/182294-simple-i-bet-but-i-still-need-a-bit-of-guidance/#findComment-961944 Share on other sites More sharing options...
ToonMariner Posted November 20, 2009 Author Share Posted November 20, 2009 ALIAS - Jesus H... could not see woods for trees. Thanks buddy. Quote Link to comment https://forums.phpfreaks.com/topic/182294-simple-i-bet-but-i-still-need-a-bit-of-guidance/#findComment-961966 Share on other sites More sharing options...
JAY6390 Posted November 20, 2009 Share Posted November 20, 2009 I think that query was meant to start with select location_s.name as start ... Quote Link to comment https://forums.phpfreaks.com/topic/182294-simple-i-bet-but-i-still-need-a-bit-of-guidance/#findComment-961967 Share on other sites More sharing options...
JustLikeIcarus Posted November 20, 2009 Share Posted November 20, 2009 haha yes @JAY6390 you are exactly right. Quote Link to comment https://forums.phpfreaks.com/topic/182294-simple-i-bet-but-i-still-need-a-bit-of-guidance/#findComment-961968 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.