Mysql: How to get every rows that have more than a certain number of decimal after the dot

前端 未结 6 774
天命终不由人
天命终不由人 2020-12-19 17:12

I have a table that contains float values.

table

+   id   |  value  |
+--------|---------|
+   1    | 19.22   |
+   2    | 32.333  |
+   3    | 1.         


        
6条回答
  •  不知归路
    2020-12-19 17:48

    This regex (MySQL 5.0+) worked for me, based on the data you provided:

    SELECT t.* 
      FROM YOUR_TABLE t 
     WHERE t.`value` REGEXP '[0-9]+.[0-9][0-9][0-9]+'
    

    Reference:

    • http://www.regular-expressions.info/

提交回复
热议问题