当列不进行编译时,Mysql条件情况

时间:2016-11-27 09:46:01

标签: mysql

SELECT 
    DISPLAY_ID,
    PICKER_NAME,
    CREDIT,
    HOURLY_RATE,
    DAILY_RATE,
    WEIGHT,
    CASE
        WHEN (DeviceGroups IS NOT NULL AND WorkerGroups IS NOT NULL) THEN CONCAT(DeviceGroups,',',WorkerGroups);
        WHEN (DeviceGroups IS NULL AND WorkerGroups IS NOT NULL) THEN WorkerGroups;
        WHEN (DeviceGroups IS NOT NULL AND WorkerGroups IS NULL) THEN DeviceGroups;
        WHEN (DeviceGroups IS NULL AND WorkerGroups NOT NULL) THEN NULL;
    END as GROUPS
FROM....

我尝试使用Case When语法和alians一样,我收到了这个错误:

  

SQL查询:文档

SELECT DISPLAY_ID,PICKER_NAME,CREDIT,HOURLY_RATE,DAILY_RATE,WEIGHT, 案件 什么时候(

DeviceGroups不是NULL AND WorkerGroups不是NULL ) 那么CONCAT(DeviceGroups,',',WorkerGroups);

MySQL说:文档

1064 - 您的SQL语法出错;检查与MySQL服务器版本对应的手册,以便在第9行

附近使用正确的语法

1 个答案:

答案 0 :(得分:2)

删除分号:

Traceback (most recent call last):
File "C:/Users/UT/PycharmProjects/tkinter/python_PET/main.py", line 16, in <module>
    m = menu_bar_class(root)
File "C:/Users/UT/PycharmProjects/tkinter/python_PET/main.py", line 14, in __init__
    self.master.config(self.menu)
File "C:\Python27\lib\lib-tk\Tkinter.py", line 1326, in configure
    return self._configure('configure', cnf, kw)
File "C:\Python27\lib\lib-tk\Tkinter.py", line 1312, in _configure
    cnf = _cnfmerge(cnf)
File "C:\Python27\lib\lib-tk\Tkinter.py", line 114, in _cnfmerge
    for c in _flatten(cnfs):
AttributeError: Menu instance has no attribute '__len__'

在标准SQL中,分号(;)用于结束查询。