I need to find, for example, a user by his posts id
. Database with users and posts may look like this:
Users:
id | username | password
---+----------+---------
1| John| ****
2| Eve| ****
3| Rich| ****
Posts:
id | author_id | contents
---+-----------+---------
1| 1| I'm John
2| 2| I'm Eve
3| 3| I'm Rich
4| 3| It's Rich not rich, keep that on mind...
My situation is just slightly different from post<->user situation, because in my case, I don't need any information about post.
So according to the above, and with help of some random posts I found (with MySql problems I never know what to search on google) I thought my query should look like this:
SELECT username, id
FROM `user`
WHERE id IN (SELECT author_id FROM `post` WHERE author=$MYID)
This does not work, so I guess more magic than mysterious IN
statement will be needed.