每個人我都想用動態行對MySQL進行查詢。mysql動態行
想象一下:
表phones_categories
+----+------------+
| id | name |
+----+------------+
| 1 | Home Phone |
| 2 | Cell Phone |
| 3 | Fax |
+----+------------+
臺手機
+----+-----------+-------------------+--------------+
| id | entity_id | phone_category_id | phone_number |
+----+-----------+-------------------+--------------+
| 1 | 1 | 1 | X19 XXX 2XX |
| 2 | 1 | 3 | X19 XXX 2XX |
| 3 | 2 | 1 | X18 XXX 4XX |
| 4 | 2 | 3 | X18 XXX 4XX |
+----+-----------+-------------------+--------------+
我想有以下輸出:
+-----------+--------------+--------------+-------------+
| entity_id | Home Phone | Cell Phone | Fax |
+-----------+--------------+--------------+-------------+
| 1 | X19 XXX 2XX | | X19 XXX 2XX |
| 2 | X18 XXX 4XX | | X18 XXX 4XX |
+-----------+--------------+--------------+-------------+
好吧,我需要一些「動態」因爲未來phone_categories表可以增長。
爲什麼貶我的問題? – workdreamer