I’m trying to create some filtering options for the user to allow them to filter the data the see in the table. Here is what I have:
WHERE
projects.state = {Root Container.drpStateSel.selectedValue}
AND {Root Container.cbStateFilter.selected} = 1
This will apply the filter when the dbStateFilter check box is checked.
What i need help with is, I want to return all the records when the filter is turned off and order by the latest record which I can use projects.id ASC for that. But what i really need is an IF( statement in the SQL query but I can’t seem to get that to work. I tried this:
IF({Root Container.rb_RemoveFilter.selected} = 0, WHERE
projects.state = {Root Container.drpStateSel.selectedValue}
AND {Root Container.cbStateFilter.selected} = 1, ORDER BY projects.id)
But I get this Error
Exception: Error running query:
SQLQuery(query=SELECT
*
FROM
projects
JOIN
customers
on (projects.cust=customers.id)
JOIN
proj_state
on (projects.state=proj_state.id)
IF(1 = 0, WHERE
projects.state = 1
AND 0 = 1, ORDER BY projects.id)
, database=)@0ms
On: Overview.Root Container.Table.data
caused by GatewayException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘IF(1 = 0, WHERE
projects.state = 1
AND 0 = 1, ORDER BY projects.id)’ at line 11
caused by MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘IF(1 = 0, WHERE
projects.state = 1
AND 0 = 1, ORDER BY projects.id)’ at line 11
Ignition v7.3.3 (b570)
Java: Oracle Corporation 1.7.0_02