Jump to content

[SOLVED] Is a Join needed?


karatekid36

Recommended Posts

In this query:

SELECT * FROM prof_ratings WHERE prof_id=$prof_id ORDER BY date_entered DESC;

 

One of the row items pulled is user_id.  I have a user table which has a primary key of user_id.  In this new query, I would like to have the user name pulled and put into my web page instead of simply displaying the user_id.  In the user table, the name is broken into first_name and last_name.  How can I pull the user's name with this query so that I can place it in my web page?

 

Thanks

Link to comment
Share on other sites

yes a join is needed

select prof_ratings.* from prof_ratings, user.first_name, user.last_name

from prof_ratings

JOIN user on user.user_id = prof_ratings.prof_id

 

that will get you the names of all the profs.

I am sorry I don't know how to put the where clause in join form since I am struggling with the same problem

look here for more information (read the first link in fenways post, reply#3)

http://www.phpfreaks.com/forums/index.php/topic,150081.0.html

 

If I figure out how to do the where clause in a join syntax I ll post it here too

 

anatak

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.