I'm not sure if this has to do with the join statement or with table linking but here it goes.
I have 2 tables, 1 is with users, the other is a friends table (indicating which users are friends)...
Users (not complete, just to give idea):
u_id
u_email
u_password
u_handle
u_photo
PRIMARY KEY (u_id)
Friends table:
f_id
f_mhandle
f_fhandle
PRIMARY KEY (f_id)
Now, I don't store the user photo in the friends table for obvious reason, but I do store the "Friends Handle" and the "My Handle". u_ids are not stored for a reason.
Now, I want to somehow pull the u_photo from users table when I'm doing a query on the friends table so that I can pull a photo for each friend.
Current query: "SELECT * From friends WHERE f_fhandle=$friend ORDER BY f_id DESC LIMIT 1000"
No idea on how I can pull the photo for a user where friends.f_fhandle=users.u_handle. If necessary to add a photo column to the friends list I can do that but I don't want to store the actual photo there because its updated in the users table and I don't want to repopulate things.
I think there is a way to do this using JOIN command or using table linking, but I am not sure how to link tables on mysql.
Thanks!
Luc L.
I have 2 tables, 1 is with users, the other is a friends table (indicating which users are friends)...
Users (not complete, just to give idea):
u_id
u_email
u_password
u_handle
u_photo
PRIMARY KEY (u_id)
Friends table:
f_id
f_mhandle
f_fhandle
PRIMARY KEY (f_id)
Now, I don't store the user photo in the friends table for obvious reason, but I do store the "Friends Handle" and the "My Handle". u_ids are not stored for a reason.
Now, I want to somehow pull the u_photo from users table when I'm doing a query on the friends table so that I can pull a photo for each friend.
Current query: "SELECT * From friends WHERE f_fhandle=$friend ORDER BY f_id DESC LIMIT 1000"
No idea on how I can pull the photo for a user where friends.f_fhandle=users.u_handle. If necessary to add a photo column to the friends list I can do that but I don't want to store the actual photo there because its updated in the users table and I don't want to repopulate things.
I think there is a way to do this using JOIN command or using table linking, but I am not sure how to link tables on mysql.
Thanks!
Luc L.