ठीक है, मैं आपको समझाता हूं कि यह कैसा होगा। मैंने दो तालिकाओं के साथ एक उदाहरण बनाया है जिसे आप नीचे देख सकते हैं।
फिर आप अपनी क्वेरी बना सकते हैं।
mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| addresses |
| students |
+----------------+
2 rows in set (0.00 sec)
mysql> select * from students;
+----+----------+-----------+
| id | name | last_name |
+----+----------+-----------+
| 1 | jhon | smith |
| 2 | anderson | neo |
| 3 | trinity | jackson |
+----+----------+-----------+
3 rows in set (0.00 sec)
mysql> select * from addresses;
+----+-----------------+---------+
| id | address | student |
+----+-----------------+---------+
| 1 | Av 1 2nd Street | 1 |
| 2 | Av 3 4 Street | 2 |
| 3 | St 23 7 Av | 3 |
+----+-----------------+---------+
3 rows in set (0.00 sec)
mysql> select s.name,s.last_name,a.address from students s join addresses a on a.student=s.id;
+----------+-----------+-----------------+
| name | last_name | address |
+----------+-----------+-----------------+
| jhon | smith | Av 1 2nd Street |
| anderson | neo | Av 3 4 Street |
| trinity | jackson | St 23 7 Av |
+----------+-----------+-----------------+
3 rows in set (0.00 sec)