Selecting info from multiple tables for one unique ID with PHP and MySQL
- by Mark
I'm using PHP and MySQL. Is this the best method to select information about "user_1" from four different tables? I know it works, because I have tried it. But is this the preferred method of selecting information from multiple tables for "user_1"?
$query = "SELECT table_1.username, table_2.city, table_3.state, table_4.country
FROM table_1
JOIN table_2
ON table_1.username=table_2.city
JOIN table_3
ON table_1.username=table_3.state
JOIN table_4
ON table_1.username=table_4.country
WHERE table_1.username = 'user_1'";