我已經完成了一些複雜的SQL查詢,但從未通過多個值連接兩個表,並且我不確定是否有可能。MySQL - 在查詢中將用戶用戶名映射到用戶ID
我有以下兩個表:
users
+-------+----------+
| u_ID | username |
+-------+----------+
| 1 | Pablo |
+-------+----------+
| 2 | Mike |
+-------+----------+
Messages
+-------+----------+---------+
| m_ID | auhor_id | message |
+-------+----------+---------+
| 1 | 2 | Heelo5 |
+-------+----------+---------+
| 2 | 1 | he4532 |
+-------+----------+---------+
| 3 | 2 | he4111 |
+-------+----------+---------+
| 4 | 1 | he4538 |
+-------+----------+---------+
將我需要什麼SQL查詢來獲取這個表?
+-------+----------+---------+
| m_ID | username | message |
+-------+----------+---------+
| 1 | Mike | Heelo5 |
+-------+----------+---------+
| 2 | Pablo | he4532 |
+-------+----------+---------+
| 3 | Mike | he4111 |
+-------+----------+---------+
| 4 | Pablo | he4538 |
+-------+----------+---------+
謝謝,這是我需要什麼,開始我處理的其他條件,我只是想做出儘可能簡單的例子。 – Pablo 2010-08-31 00:34:31