错误:AND的参数必须为布尔型,而不是文本型

时间:2019-04-03 10:01:47

标签: mysql sql

我对下面的查询感到困惑,请问这是怎么回事?

SELECT * FROM my_table 
WHERE 
    col_A <> 'Hello'
    AND col_B <> 'Holla'
    AND col_B <> 'Bonjour'

    AND (CASE WHEN col_c = 6 AND Language_col = 'Fr'THEN 'Français'
       WHEN col_c  = 9  AND Language_col = 'Fr'THEN 'Français'        
       WHEN col_c  = 12 AND Language_col = 'Eng' THEN 'English'
       WHEN col_c  = 4 AND Language_col = 'US' THEN 'Engish'
       ELSE Language END)

order by Date_col  

我遇到这种错误:

  

错误:AND的参数必须为布尔型,而不是文本

2 个答案:

答案 0 :(得分:1)

如果需要新列,则 mean std size A (0, 1] 0.465408 NaN 1 (1, 2] 0.522665 0.149038 4 (2, 3] NaN NaN 0 (3, 4] 0.571255 0.441983 3 (4, 5] 0.659662 NaN 1 (5, 6] 0.394901 0.385560 2 (6, 7] 0.117359 0.107011 2 (7, 8] 0.268144 NaN 1 (8, 9] 0.541056 0.434788 3 (9, 10] 0.593431 0.173556 3 表达式需要输入case,而不是select

where

答案 1 :(得分:0)

对于以下情况,您需要添加一些过滤器值-

SELECT * FROM my_table 
WHERE 
    col_A <> 'Hello'
    AND col_B not in ('Holla', 'Bonjour')
    AND (CASE WHEN col_c = 6 AND Language_col = 'Fr'THEN 'Français'
       WHEN col_c  = 9  AND Language_col = 'Fr'THEN 'Français'        
       WHEN col_c  = 12 AND Language_col = 'Eng' THEN 'English'
       WHEN col_c  = 4 AND Language_col = 'US' THEN 'Engish'
       ELSE Language END in ('Français','English'))
order by Date_col