Jump to content

Where clause query question


michaelkirby

Recommended Posts

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??

 

 

Link to comment
https://forums.phpfreaks.com/topic/197908-where-clause-query-question/
Share on other sites

$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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.