Reputation: 23
I would need a SELECT statement which returns a Boolean value based on the result of two independent Boolean columns (connected with 'OR'). Does anybody have the syntax for this?
Upvotes: 0
Views: 252
Reputation: 23
Thanks, the comment of jarlh solved it: "Simply select col1 or col2 from tablename"
Upvotes: 0
Reputation: 595
in MySQL you can use IF()
Function, like this:
SELECT IF(bool1 = 'true' OR bool2 = 'true', 'true', 'false')
FROM Yourtable;
Upvotes: 0
Reputation: 11
Select case when (boolean condition) then column name from table name.
You can add multiple case condition to fetch the columns of conditional basis
Upvotes: 0
Reputation: 1269873
If your database supports boolean
, then you can simply put the or
expression in the select
:
select t.*, (bool_col1 or bool_col2) as new_bool_col
from t;
Upvotes: 1