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? Quote Link to comment 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] ) Quote Link to comment 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? Quote Link to comment 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.