Reputation: 57176
I keep getting this error for my sqlite if-condition query below,
SELECT *
FROM speckdata AS s
LEFT JOIN weatherunderground AS w
ON s.wid_timestamp = w.wid_timestamp
LEFT JOIN nodes AS n
ON n.nid = s.nid
AND n.datatype = 'speck'
WHERE DATE(localdate) BETWEEN '2014-10-09' AND '2015-05-12'
AND n.nid = '9'
CASE WHEN 'polar plot' != NULL THEN w.wspdi != '-9999' ELSE w.wspdi != NULL END
Error,
near "CASE": syntax error ] Exception Name: NS_ERROR_FAILURE Exception Message: Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [mozIStorageConnection.createStatement]
Any ideas?
Upvotes: 0
Views: 1921
Reputation: 44833
Your CASE
expression has nothing to do with the rest of the statement --- it isn't connected in any way. It looks like you're trying to add a condition to the WHERE
clause, but you don't have an AND
or OR
there. So, you get a syntax error because you have a query followed by a random unconnected expression.
Upvotes: 1