Hey guys I have a question which is how to get information from one tables and then with that info e.g. a name and then query the database to tell me a value in table 2.
So in short I have a friend system going but I cant get the pictures for that user because it is in another table. I can get his name but i can not get his picture. So how do you get his picture which is in table 1 and the name is in table 2.
table 1
name Users
id username password Email picture theme
1 bob dabsd2323ty hjas@hsdf uploads/adsda.png themes/theme1.png
2 fred dabsd2323ty hjas@hsdf uploads/adsda.png themes/theme1.png
table 2
name Friends
id sender receiver checked
1 bob fred 2
2 means he has checked it and accepted it.
so i can get the name from table 2 but i dont know how to get the picture for the user from table 1
This is a classic JOIN query. Whose picture do you want, the sender’s or the receiver’s? Let’s get the picture for the receiver:
If you want a specific user only, add the condition
sender = 'Jim'or something like that to the query.You can also JOIN a table twice. Suppose you want to get the picture of both the sender and the receiver: