How can I write SQL with deleted_at, NULL, NOT NULL?

Hello, I am very new in Retool.
I want to filter my data with SelectBox related to “deleted_at” column. It has three options such as “ALL”, “NULL”, “NOT NULL”.

SELECT *
FROM DATA
WHERE
AND
( {{ !MySelectBox.value == “ALL” }} OR deleted_at IS {{ MySelectBox.value }}

As you know, it does not work because the value is String (in MySQL). I want to use NOT or NOT NULL query when the SelectBox has some value. How can I do this? Do I have to split it two queries?

Hey @smyang1 and welcome to the community! Yep, you’ll probably want to split this up into multiple queries, and use a Run JS Code query to route which query to use based on the value of your dropdown (you can trigger queries via query.trigger()).