If I have one MySQL database table where two rows contain a userid and i want to get the usernames for both userids, how would I do this without doing a query in the while-loop?
For an example, I have a log where the id of the user who made a change and the id of the user who has been changed is saved, so I have a table that looks something like this:
entryid userid changeduser etc...
Now I have another table where the userids and the usernames are stored, something like
userid username etc...
I know how to join both tables to get one userid, but I can't figure out how to get both usernames within one query.
Can someone help me out?
For an example, I have a log where the id of the user who made a change and the id of the user who has been changed is saved, so I have a table that looks something like this:
entryid userid changeduser etc...
Now I have another table where the userids and the usernames are stored, something like
userid username etc...
I know how to join both tables to get one userid, but I can't figure out how to get both usernames within one query.
Can someone help me out?
Comment