我有一个名为 [clients] 的下表,其列和值如下:
+--------+-----------+--------------+----------------+
| uid | client_id | client_input | input_value |
+--------+-----------+--------------+----------------+
| 1 | 22 | City | Seattle |
+--------+-----------+--------------+----------------+
| 2 | 45 | City | Ojai |
+--------+-----------+--------------+----------------+
| 3 | 22 | State | OR |
+--------+-----------+--------------+----------------+
| 4 | 45 | State | CA |
+--------+-----------+--------------+----------------+
| 5 | 65 | City | Orlando |
+--------+-----------+--------------+----------------+
| 6 | 74 | State | AB |
+--------+-----------+--------------+----------------+
| 7 | 65 | State | FL |
+--------+-----------+--------------+----------------+
| 8 | 12 | City | Los Angeles |
+--------+-----------+--------------+----------------+
| 9 | 12 | State | CA |
我需要PHP/MySql 查询,该查询将列出input_value列中位于“CA”状态的所有城市。显然,通用标识符是始终匹配的client_id,因为如果客户端在“洛杉矶”,则相同的 client_id 也在input_value列中包含“CA”值的行中。该表有超过 800 万行,任何快速执行的 equerry 都受到高度赞赏。
脑筋急转弯,截止日期快到了,无法更改表设计,需要帮助,拜托!