tibberous Posted September 4, 2008 Share Posted September 4, 2008 I have a row in a database that can be either be linked to an account or a location. It will always have an account_id, it might have a location_id. If it has a location_id, I want to return the linked row from the location table, otherwise, I want it to just return the record. Is there a way to select from two tables, but always select from at least one? Link to comment https://forums.phpfreaks.com/topic/122646-how-to-do-this/ Share on other sites More sharing options...
Ken2k7 Posted September 4, 2008 Share Posted September 4, 2008 SELECT * FROM `table1` INNER JOIN `table2` ON ( [conditions] ) Link to comment https://forums.phpfreaks.com/topic/122646-how-to-do-this/#findComment-633305 Share on other sites More sharing options...
tibberous Posted September 4, 2008 Author Share Posted September 4, 2008 What would my condition be? Just `row`.`location_id`=`table2`.`id`? And if it fails it doesn't join? Link to comment https://forums.phpfreaks.com/topic/122646-how-to-do-this/#findComment-633308 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.