使用多值 SQL 搜索多列 [英] Searching Multiple Columns with Multiple Values SQL

查看:24
本文介绍了使用多值 SQL 搜索多列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道可以用一个值搜索多个列.

I know it is posible to serach multiple columns with one value.

我想为 4 个或 5 个值搜索 3-4 列

I would like to serach 3-4 columns for 4 maybe 5 values

我想检查我选择的任何列中是否有特定值.

I want to check if any of my choosen columns have a certain value in them.

例子

Column 1 | Column 2 | Column 3 | Column 4 
         |          |          |
Hello    |          |          |            = True
         |          |          |
         | Goodbye  |          |            = True
         |          |  Hello   | Goodbye    = True
         |          |          |
         | Hello    |          |            = True
         |          |          |
         |          |  Goodbye |            = True

在示例中,我希望 SQL 从所有包含 Hello 或 Goodbye 的行中提取数据,甚至在某些情况下.

In the example I would like SQL to pull the data from all of the lines that have Hello or Goodbye even both in some cases.

有没有办法做我想做的事?

Is there a way to do what I want?

推荐答案

还有一种方法...

SELECT *
FROM TableName
WHERE 'Value1' IN (Col1,Col2,Col3...) OR 'Val2' in (Col1,Col2,Col3...) OR ...

这篇关于使用多值 SQL 搜索多列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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