Variables in SQL within IF THEN ELSE

I’m trying to use variables in mysql.
Assume I have the following.
Variable ‘dogs’ that is of type text and has no default value.
what I need to do is something like this :
SELECT
IF {{dogs}} IS NOT NULL
THEN
dogs
ELSE
*
END IF
FROM myTable;

Hi @bpatton
You are looking for complex default values:
https://www.metabase.com/docs/latest/users-guide/13-sql-parameters.html#default-value-in-the-query

SELECT
[[ `dogs`, {{dogs}} AS "returned" -- ]] *
FROM `table`

But because you are trying to use this outside of the WHERE-clause and because of how the variable replacement is done, you cannot hide the variable in the comment.

That would like be fixed if this issue gets fixed, but there are several problems involves with parsing SQL and removing comments, since Metabase supports many databases in various versions.
https://github.com/metabase/metabase/issues/7742 - upvote by clicking :+1: on the first post