Im trying to do an blog that shows all the comments and user will be able to post comments on reply on previously posted comments no to order then in the sql query so they will show up in order i keep getting the error.
SELECT c.userid, c.comment, c.reply, u.username, c.createdat, c.image, c.username as
ComUser FROM Bundle:Comments c LEFT JOIN Bundle:Users u WITH c.userid = u.id
WHERE c.articleid = 1 ORDER BY (CASE WHEN (c.parentid = 0) THEN c.id ELSE c.parentid END)
c.createdat ASC
Gives Error: [Syntax Error] line 0, col 515: Error: Expected end of string, got 'CASE'
even tried normal way
ORDER BY IF(c.parentid = 0, c.id, c.parentid), c.createdat ASC
Gives Error: [Syntax Error] line 0, col 515: Error: Expected end of string, got '('
When i use the normal ORDERY BY IF() in normal sql code (not doctrine) it works fine.
looks like you just have a typo. Your overall syntax is correct.
ORDER BY CASE WHEN (c.parentid = 0) THEN c.id ELSE .parentid END c.createdat ASC
should be
ORDER BY CASE WHEN (c.parentid = 0) THEN c.id ELSE c.parentid END, c.createdat ASC
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With