michaelkirby Posted April 7, 2010 Share Posted April 7, 2010 Hi all, I'm creating a query as follows: $query ="select * from brief, subscriptions where brief.briefid = subscriptions.briefid"; What I'm trying to achieve is I have a many to many relationship and want to be able to display that tables details which is called subscriptions. As only the brief id is stored in subscriptions I join the tables to get the name of the brief from brief table. This all works fine but I need some advice on adding another where clause in. I want to be able to select the above data but for the user logged in. So I have the user id in the session but how do I append it to the end of the query as I was getting errors doing it. Any one able to help?? Quote Link to comment https://forums.phpfreaks.com/topic/197908-where-clause-query-question/ Share on other sites More sharing options...
schilly Posted April 7, 2010 Share Posted April 7, 2010 post the query giving the error. Quote Link to comment https://forums.phpfreaks.com/topic/197908-where-clause-query-question/#findComment-1038514 Share on other sites More sharing options...
michaelkirby Posted April 7, 2010 Author Share Posted April 7, 2010 $query ="select * from brief, subscriptions where brief.briefid = subscriptions.briefid and userid = $userid"; Error reads... Unable to preform query.br /> select * from brief, subscriptions where brief.briefid = subscriptions.briefid and userid = 1 Column 'userid' in where clause is ambiguous Quote Link to comment https://forums.phpfreaks.com/topic/197908-where-clause-query-question/#findComment-1038515 Share on other sites More sharing options...
Mchl Posted April 7, 2010 Share Posted April 7, 2010 You have to indicate in which table is the userid column you're refering to. Quote Link to comment https://forums.phpfreaks.com/topic/197908-where-clause-query-question/#findComment-1038516 Share on other sites More sharing options...
michaelkirby Posted April 7, 2010 Author Share Posted April 7, 2010 Thanks very much I knew I would be missing something small!!! Thanks Quote Link to comment https://forums.phpfreaks.com/topic/197908-where-clause-query-question/#findComment-1038519 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.