Is it possible to change the value of a field in a SELECT query, from within the HAVING part of the query? I don't want to touch the data in the database, this is just the values that come back in the select.
Here's a contrived example as the real query in question is very long and complicated.
SELECT t.col1, t.col2, (@all_is_ok = TRUE) as all_is_ok
FROM table t
WHERE t.col1 = 'something'
HAVING (
(t.col2 = 1 AND t.col3 = 1)
OR (t.col2 = 2 AND t.col3 = 2)
OR (SET @all_is_ok = FALSE) /* If we get into this final OR in the HAVING
then I want the column all_is_ok to be set
to FALSE so that I still get the row back,
but can see that the row wasn't as expected */
)
We're using MariaDB 10.4.
I hope that makes sense and someone can help. Thank you.