开发者

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! :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜