I have a question… Suppose that I have a table that holds names of cities. something like this:
id name
1 Los Angeles
2 Madrid
And I have a table for users:
uid username locationid hometownid
1 John 1 2
in which John is a user whose current location is Los Angeles and his hometown is Madrid.
Is there anyway that I can retrieve the user’s current location name and hometown name in one row with a SELECT query? If it’s impossible, do you have any suggestions for a change in the database structure to make it possible?
Yes, and it’s extremely trivial – just add a JOIN to each relevant field in the user table.