Padgoi Posted August 21, 2008 Share Posted August 21, 2008 Hey guys, I have this query that looks like this: $rating = mysql_query( "SELECT member_id,field_11 FROM ibf_pfields_content ORDER BY field_11 desc" ) This query calls the member id and field 11 from the table ibf_pfields_content. The problem is that member_id is just a number associated with a user. The member_id field is EQUAL to another field in another table. In other words: Table Name = ibf_pfields_content Field name = member_id Field name = field_11 Table name = ibf_members Field name = id <b>= member_id field from ibf_pfields_content table</b> Field name = name I need to associate the member_id field from ibf_pfields_content to equal the id field from the ibf_members table and then after doing that, I need to call up the name field from the ibf_members table so that instead of showing the user id, it will show the user name. Can anyone help me with this? I'd be very appreciative. Thanks! Quote Link to comment Share on other sites More sharing options...
toplay Posted August 21, 2008 Share Posted August 21, 2008 Use a join: SELECT im.name , ipc.field_11 FROM ibf_pfields_content ipc JOIN ibf_members im ON im.id = ipc.member_id ORDER BY ipc.field_11 DESC Quote Link to comment Share on other sites More sharing options...
AjBaz100 Posted August 21, 2008 Share Posted August 21, 2008 OR SELECT im.name , ipc.field_11 FROM ibf_pfields_content ipc, ibf_members im WHERE im.id = ipc.member_id ORDER BY ipc.field_11 DESC The first post is the better way though..! Quote Link to comment Share on other sites More sharing options...
Padgoi Posted August 21, 2008 Author Share Posted August 21, 2008 Thanks fellas. Resolved. Quote Link to comment 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.