does quoting order by matter?
I am using mysql and the following two sqls produce different result.
SELECT developers.* FROM "developers" ORDER BY id DESC LIMIT 1开发者_如何学运维
SELECT developers.* FROM "developers" ORDER BY 'id DESC' LIMIT 1
I thought that quoting order by should not matter.
By quoting the order you are ordering by the literal string 'id DESC', which would indeed change the result, since it's pretty meaningless - little different to saying ORDER BY 1
ORDER BY 'id DESC' is saying "ORDER BY the constant string 'id DESC'". Don't quote the ORDER BY! :)
精彩评论