lundi 17 novembre 2014

Order a VARCHAR column numerically


Vote count:

0




Current SQL: SELECT code FROM myTable ORDER BY code ASC


code

---

11

113

12

13A


This is the current order I have of a MySQL table.


I want the order to be A-Z, 1-10 however, numerically, like this:


code

---

11

12

13A

113


The reason this is not possible in the first place is because the code column is varchar and not int. However as shown in the example, some codes have a letter prepended to them so I cannot change this to integer.


How can I get around this problem without changing the data type?



asked 1 min ago

jskidd3

1,055






Order a VARCHAR column numerically

Aucun commentaire:

Enregistrer un commentaire