Friday, 16 April 2010

What is order by length in mysql?

+------+
| code |
+------+
| A10  |
| A20  |
| A5   |
| A6   |
| A7   |
| A8   |
| A9   |
+------+

You can query like this:
mysql> select * from table order by length(code), code;

+------+
| code |
+------+
| A5   |
| A6   |
| A7   |
| A8   |
| A9   |
| A10  |
| A20  |
+------+
  
Cheers! 

1 comment:

  1. Really awesome blog. Your blog is really useful for me. Thanks for sharing this informative blog. Keep update your blog.
    Hire PHP Mysql Developer in India

    ReplyDelete