sql statement to query common minor problems

1. When the maximum value search check the version of the database field, such as  version  type varchar  

查询语句   select * from tab_1 where version =(select max(version) from tab_1)

At this time, when the query version version 1-9 data when normal version has been more than 10 inquiries 9

Solution  

select max(cast(version as UNSIGNED INTEGER)) from  tab_1   

Reason: The query varchar 9 10 11 9 maximum (to say the very simple ...) as long as the format conversion can be a normal query

Guess you like

Origin www.cnblogs.com/Watson-Z/p/12420169.html