MySQL Forums
Forum List  »  Newbie

Selecting from multiple tables
Posted by: Chrys Bader
Date: August 15, 2005 09:49AM

I am trying to select from three different tables. I can select from two of the tables, but once I add another table into the WHERE clause, there are no results.

here is my query:

SELECT k.keyword, k.keyword_id, l.label, uk.searchable, uk.displayable, uk.profile, uk.comment

FROM    keywords as k, user_keywords as uk, labels as l
            
WHERE  uk.user_id = $userid AND uk.keyword_id = $id AND k.keyword_id = $id AND l.label_id = uk.label_id";

What I am trying to do is get the name of the label (l.label) from the labels table where the label_id in the labels table is the same as the label_id that is in the user_keywords table. I have done this before successfully. This time, all of the other ids are provided (user id and keyword id), but we must distinguish what the label id is in the scope of the MySQL statement. Sorry if this is confusing, can anyone provide some insight?

Thanks a bunch,
Chrys

Options: ReplyQuote


Subject
Written By
Posted
Selecting from multiple tables
August 15, 2005 09:49AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.