dhope Posted August 20, 2010 Share Posted August 20, 2010 Hi, I'm trying to select three tables from my database to retrieve some information. But when I add more than one table I get the following error "Column 'user_id' in where clause is ambiguous". I've tried a few different ways and had a read up online, but can seem to fix it. Please can someone point me in the right direction? my code... $page_settings = mysql_query(" SELECT * FROM settings, seo, pages WHERE user_id = '$user_id' ") or die(mysql_error()); $settings = mysql_fetch_array( $page_settings ); Quote Link to comment https://forums.phpfreaks.com/topic/211316-clause-is-ambiguous/ Share on other sites More sharing options...
kickstart Posted August 20, 2010 Share Posted August 20, 2010 Hi If a column name is not unique in a SELECT you need to specify which table the column belongs to at any place you use the column. ie SELECT OWNER.NAME, DOG.NAME, OWNER.AGE, DOG.AGE FROM OWNER INNER JOIN DOG ON OWNER.ID = DOG.OWNERID Both the owner and dog tables have columns for name and age, hence you need to specify which one you are referring to All the best Keith Quote Link to comment https://forums.phpfreaks.com/topic/211316-clause-is-ambiguous/#findComment-1101922 Share on other sites More sharing options...
dhope Posted August 21, 2010 Author Share Posted August 21, 2010 Thank you Quote Link to comment https://forums.phpfreaks.com/topic/211316-clause-is-ambiguous/#findComment-1102006 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.