开发者

How do I order by in mysql when the value are alpha numeric?

I need to order a queries results by the name which is a varchar(50) from the bundles table. The table contains the following values for name:

# 'Package 1', 'Package 2', 'Package 3', 'Package 10' etc.
SELECT name FROM bundles ORDER BY name ASC;

This query returns the following order:

Package 1
Pac开发者_如何学Pythonkage 10
Package 11
Package 2
Package 3
etc...

Is there anyway with mysql to make it order naturally:

Package 1
Package 2
Package 3
...
Package 10

or is this something i will have to code manually with the results.

I have tried:

ORDER BY ABS(name)
and
ORDER BY (name+0)

on suggestions found around the web, neither work.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜