我有这张桌子
ADDS
(1)
+----+--------------+--------------+
| id | name of add | Date |
+----+--------------+--------------+
| 1 | Add01 | March 01 |
| 2 | Add02 | March 02 |
| 3 | Add03 | March 03 |
| 4 | Add04 | March 04 |
+----+--------------+--------------+
TYPE OF ADDS
(2)
+----+----------+
| id | Add id |
+----+----------+
| 21 | 1 | NOTE: Add id of table (2) = id of table (1)
| 22 | 2 |
| 23 | 3 |
| 24 | 4 |
+----+----------+
NAMES OF TYPES
(3)
+----+-----------+--------------+
| id | Type id | Name |
+----+-----------+--------------+
| 31 | 21 | Text add |
| 32 | 22 | Banner | NOTE: Type id of table (3) = id of table (2)
| 33 | 23 | Video add |
| 34 | 24 | Other |
+----+-----------+--------------+
我需要这样的报告:
+--------+-----------+--------------+
| Add id | Add name | Type of add |
+--------+-----------+--------------+
| 1 | Add01 | Text add |
| 2 | Add02 | Banner |
| 3 | Add03 | Video add |
| 4 | Add04 | Other |
+--------+-----------+--------------+
(Add id
来自表(1),Add name
来自表(1),Type of add
来自表(3))
到目前为止,我可以做一个SELECT query LEFT JOIN table 1 and 2
,但我不知道如何Name of type
从表 3 返回值。我该怎么做?