Skip to content
Advertisement

How to select 2 boolean columns and retrieve 1 boolean result (both must be true = true)

In SQL Server I have multiple bit columns. If either the product = False or the Category = False, I want to return False.

My test code:

But all 3 selects crash.

My actual code snippet:

Of course I can do this with two If-Thens but my current query is pleasantly one clean query so I was hoping to do this in one neat line.

Advertisement

Answer

You are very close, booleans should use boolean logic:

Use & for and, | for or

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement