I have a MySQL table of the form:
id | error 1 | error 2 | error 3 | error 4 |
--------------------------------------------
1 | 1 | 0 | 0 | 1 |
-------------------------------------------
2 | 0 | 0 | 0 | 0 |
The id is the primary key and the errors are boolean columns. Is there a way where I can fetch the IDs of the rows, if any of the error is 1 as true and false if all the errors are zero.
select id,case when error1+error2+error3+error4 > 0
then 1
else 0
end as error
from Table t;
select id, case when error1 + error2 + error3 + error4 > 0
then 1
else 0
end as result
from your_table
SELECT id
FROM "your table name"
WHERE error 1 = 1
OR error 2 = 1
OR error 3 = 1
OR error 4 = 1
OR error 5 = 1