Reputation: 1058
i have below query which i want to use in my application using nodejs i ran this query in mysql works fine but when i am running this query in application it's giving below error. Any help would be appreciated.
SELECT COUNT(*) as nos, t.* FROM
streams,
trackt WHERE s.type = 1 AND s.createdAt <= 2018-07-01' AND s.createdAt >= '2018-06-01' AND t.type = 'audio' AND s.track = t.id GROUP BY s.track Order BY nos DESC, createdAt DESC LIMIT 50
error: Sending 500 ("Server Error") response: { Error: ER_PARSE_ERROR: 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 '' AND s.createdAt >= '2018-06-01' AND t.type = 'audio' AND s.track = t.id GROUP ' at line 1
Upvotes: 0
Views: 81
Reputation: 14389
you are missing and opening quote:
.. AND s.createdAt <= 2018-07-01' ..
should be:
... AND s.createdAt <= '2018-07-01' ...
^^^ here
Upvotes: 2
Reputation: 56
put a ' before "2018-07-01"
SELECT COUNT() as nos, t. FROMstreams,trackt WHERE s.type = 1 AND s.createdAt <= '2018-07-01' AND s.createdAt >= '2018-06-01' AND t.type = 'audio' AND s.track = t.id GROUP BY s.track Order BY nos DESC, createdAt DESC LIMIT 50
Upvotes: 1