0

How do I create a select all statement that checks multiple columns in a single row for one value and if it doesn't have the value then exclude it from the query?

derekjs67
  • 77
  • 1
  • 1
  • 9
  • Can you share some sample data and the result you're trying to achieve? It's a bit hard to follow what you're trying to do. – Mureinik Nov 13 '14 at 18:26
  • Possible duplicate: [questions/13916400/checking-multiple-columns-for-one-value](https://stackoverflow.com/questions/13916400/checking-multiple-columns-for-one-value). – Ryan Vincent Nov 13 '14 at 18:29
  • 1
    Do all columns have to have that value or at least one? – Andrew Nov 13 '14 at 18:30

2 Answers2

6

You can do this pretty simply by reversing the normal in operator: value in (column1, column2, column3)

Allan
  • 17,141
  • 4
  • 52
  • 69
1

Use a "reversed" IN():

select ....
from ...
where someValue in ( col1, col2, col3, ...)
Bohemian
  • 412,405
  • 93
  • 575
  • 722