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
https://forums.phpfreaks.com/topic/60711-solved-is-a-join-needed/
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

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.