我有一个带有以下列/值的 mysql 表
d1 d2 d3 d4 d5
10 12 9 2 6
我无法弄清楚如何获取匹配值的列名......因为 d1
如果匹配值是 10
. 我只是想为匹配的值返回列名
这是订单列表查询。这个查询的问题是它返回所有部门的所有待处理订单。但如果我添加 AND stage
= 'd1' 我会工作我只是不知道如何从我演示的布局中获取 'd1' 或 'd2' 'd3'
SELECT `phoenix_so`.`id`, `stage`, `so_number`, `service` AS service_id, `cid`, `uid`, `pec`, `customer_name`, `phoenix_so_service`.`name` AS service, `location`, `phoenix_so_priority`.`name` AS pri, `phoenix_so_priority`.`css_class`, `phoenix_so_type`.`name` as type, `phoenix_so_type`.`css_class` AS type_css
FROM (`phoenix_so`)
LEFT JOIN `phoenix_so_service` ON `phoenix_so`.`service` = `phoenix_so_service`.`id`
LEFT JOIN `phoenix_so_priority` ON `phoenix_so`.`priority` = `phoenix_so_priority`.`id`
LEFT JOIN `phoenix_so_type` ON `phoenix_so`.`type` = `phoenix_so_type`.`id`
LEFT JOIN `phoenix_so_roadmap` ON `phoenix_so`.`service` = `phoenix_so_roadmap`.`service_id`
WHERE `inv_access_cdate` = "0000-00-00"