0

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.* 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

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

Neeraj Kumar
  • 1,058
  • 1
  • 9
  • 22

2 Answers2

2

you are missing and opening quote:

.. AND s.createdAt <= 2018-07-01' ..

should be:

 ... AND s.createdAt <= '2018-07-01' ...
                       ^^^ here
Juan Carlos Oropeza
  • 47,252
  • 12
  • 78
  • 118
apomene
  • 14,282
  • 9
  • 46
  • 72
1

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

Manita
  • 56
  • 4