搜索的case sql语句中可以有多个布尔表达式吗? [英] Can I have multiple boolean expressions in a searched case sql statement?

查看:106
本文介绍了搜索的case sql语句中可以有多个布尔表达式吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试基于许多布尔表达式创建搜索到的case sql语句.

I'm trying to create a searched case sql statement based on a number of boolean expressions.

例如

select CASE a = b OR c = d OR e = f OR g = h
THEN 'x' ELSE 'y' END
from table_name

我一直收到以下错误:Incorrect syntax near '='.

I keep getting the following error: Incorrect syntax near '='.

我是在执行SQL中固有的错误/非法操作,还是可以解决此问题?如果可以修复,该怎么办?

Am I doing something that's inherently wrong/illegal in sql, or is this something I can fix? If it is fixable, how can I do it?

谢谢!

推荐答案

select CASE when ( a = b OR c = d OR e = f OR g = h )
THEN 'x' ELSE 'y' END
from table_name

格式为CASE..WHEN..THEN..ELSE..END.您只是错过了WHEN.

The format is CASE..WHEN..THEN..ELSE..END. You were just missing the WHEN.

这篇关于搜索的case sql语句中可以有多个布尔表达式吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆