gpt4 book ai didi

php - mysql查看错误

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

我有一个像这样的 sql 查询,它给出了语法错误,但我找不到它是什么:

CREATE VIEW 
vw_hs_hr_wf_main_data AS
select mo.wfmod_id,
mo.wfmod_name,
mo.wfmod_view_name,
ty.wftype_code,
ty.wftype_description,
ty.wftype_table_name,
ty.wftype_view_name,
ma.wfmain_id,
ma.wfmain_sequence,
CASE
WHEN ap.wf_main_app_employee IS NULL
THEN ma.wfmain_approving_emp_number
ELSE ap.wf_main_app_employee
END CASE AS wfmain_approving_emp_number,
ma.wfmain_flow_id,
ty.wftype_update_field,
ty.wftype_assembly,
ty.wftype_assembly_class,
ma.wfmain_previous_id,
ty.wftype_cancelmain_field,
ma.wfmain_application_date,
ty.wftype_cancelstatus_field,
ty.wftype_appmain_field,
ty.wftype_bulk_app_flg,
ty.wftype_sort_field_name
FROM hs_hr_wf_module mo INNER JOIN hs_hr_wf_type ty
ON mo.wfmod_id = ty.wfmod_id
INNER JOIN hs_hr_wf_main ma
ON ty.wftype_code = ma.wftype_code
LEFT JOIN hs_hr_wf_main_app_person ap
ON ma.wfmain_id = ap.wfmain_id
AND ma.wfmain_sequence = ap.wfmain_sequence
WHERE (ma.wfmain_iscomplete_flg = 0);

错误信息:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CASE AS wfmain_approving_emp_number, ma.wfmain_flow_id, ty.wftype_update_fiel' at line 11

最佳答案

您不需要 END CASE 来关闭 CASE,只需 END:

END AS wfmain_approving_emp_number,

根据您的情况,更好的选择是 COALESCE调用:

COALESCE(ap.wf_main_app_employee, ma.wfmain_approving_emp_number)
AS wfmain_approving_emp_number

关于php - mysql查看错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6148163/

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