sql - Selecting and sorting numbers from mysql varchar column -


i have db of deceased persons; 1 of columns contains age @ death. since db records information in historical documents "as is", column contains things other numbers. age might entered "inf.", "6 mos.", "2 wks." etc, or empty. 90% of column plain old numbers "87" or "2".

i'm trying echo out table of oldest persons, sorted age. because of non-numeric values of age query is:

<?php ...  $sql = "select pid,first_name,surname,date,age $table age regexp '^[0-9]+$' order age desc limit 10";  ... ?> 

after age 90 results kids died aged 9. column being sorted in alphabetical order.

how sort in descending numerical order?

select pid,first_name,surname,date,cast(age signed) int_age table1 age regexp '^[0-9]+$' order int_age desc limit 10; 

Comments

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

go - golang pprof for c library code -