gpt4 book ai didi

mysql - 在mysql中查询时如何从select case中获取值

转载 作者:行者123 更新时间:2023-11-29 19:57:00 25 4
gpt4 key购买 nike

select     `event_attendees_mapping`.`attendees_status_id`
FROM
`event_attendees_mapping`
WHERE
((`event_attendees_mapping`.`event_schedule_id` = 1)
AND (`event_attendees_mapping`.`employee_code` = 'TJU_741')
)

使用此查询,我可以获得在情况和条件下转换的值。

 select case     
when (select `event_attendees_mapping`.`attendees_status_id`
FROM
`event_attendees_mapping`
WHERE
((`event_attendees_mapping`.`event_schedule_id` = 1)
AND (`event_attendees_mapping`.`employee_code` = 'TJU_741')
) )then 1

else
0
end

但在这里,我在字段列表中收到错误未知表“event_attendees_mapping”,而从查询中我能够获取值,请告诉我哪里做错了,请建议我。

最佳答案

这是你想要的吗?

select     CASE WHEN `event_attendees_mapping`.`attendees_status_id` = ????
THEN 1
ELSE 0
END as new_Col
FROM `event_attendees_mapping`
WHERE `event_attendees_mapping`.`event_schedule_id` = 1
AND `event_attendees_mapping`.`employee_code` = 'TJU_741'

关于mysql - 在mysql中查询时如何从select case中获取值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40653064/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com