I've got a table being populated from a MySQL database and that all works fine.
I need to filter the table using a Multiselect. Everything works but ONLY if there is something selected in the Multiselect. If nothing is selected I get an SQL error.
My query is:
SELECT *
FROM mytable mt
WHERE ({{ sel_multislect.value }} = '' OR {{ sel_multislect.value }} IS NULL OR mt.myrow = {{ sel_multislect.value }})
If do not chose an option from the multiselect I get the following error:
"You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'IS NULL OR s3.Shell_Style = )' at line 3"
It appears the query is not handling the situation where the sel_multislect.value is nothing, how can I fix this?
Hi Scott, thanks for the welcome and the prompt reply.
I've tried your query, and get a slightly different error:
'You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ')' at line 3'
I've also noticed it doesn't work when selecting more than one option, it errors with:
'Operand should contain 1 column(s)'
So, so far my multiselect only works when selecting one option lol
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ')' at line 3
And if I try to select 2 options from the multiselect..
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''26', '21' )' at line 3