0

我有如下查询的结果:

+------------------+------------+
| meta_key         | meta_value |
+------------------+------------+
| Destination Name | Shivapuri  |
| Destination Date | 26/03/2012 |
+------------------+------------+

我正在尝试编写一个选择语句,其列名称为目标名称和目标日期,其各自的值为 Shivapuri 和 '26/03/2012'。这怎么可能与 MY SQL 中的查询有关?

4

2 回答 2

1

沿着这些思路应该做的事情 -

SELECT
    GROUP_CONCAT(IF(meta_key = 'Destination Name', meta_value, NULL)) AS `Destination Name`,
    GROUP_CONCAT(IF(meta_key = 'Destination Date', meta_value, NULL)) AS `Destination Date`
FROM tbl_name
GROUP BY record_identifier
于 2012-04-06T11:44:26.900 回答
1
SELECT 
    (CASE WHEN meta_key = 'Destination Name' THEN meta_value END) as name,
    (CASE WHEN meta_key = 'Destination Date' THEN meta_value END) as date
FROM `yourtable`
于 2012-04-06T11:48:27.933 回答