mysql 数据库浮点型查询

mysql 数据库中如果在不清楚数据类型之前就设计好了数据库,在把数据倒入之后将是个灾难,此时会出现各种杯具,查询不到,修改不了

具体的解决办法 为 1 数据不多的情况下,清空表,重新设计字段,改为double 或者 decimal
2 数据巨大的情况下 可以使用
select * from `vip_guest` t where format(t.index_cou,1) =format(3.1,1) 


我需要这样来查
select * from table where format(ID,4) =format(3.1000,4)

或者是
select * from table where format(ID,4) =format(3.1,4)

删除语句也要注意是下边这样写的(嘿嘿):
delete from table where format(ID,4) =format(3.1000,4)

或者
delete from table where format(ID,4) =format(3.1,4)

注意:精度不能超过6.否则出错.因为float类型最多允许精确到小数点后6位.
同样的 
SELECT * FROM table WHERE concat(字段名,'')='12.1';
这样应该是也可以查到的

猜你喜欢

转载自annan211.iteye.com/blog/1894012