Mysql in the float type field, not the result of the query =

And float values ​​stored mysql display field is not the same, "=" search time will not find the data.

The reason is that in mysql, float is a float, Mysql storage is an approximation, so with pinpoint not match;

 

. Eg original query select * from bank where rate = 0.5; (not query result)

Solution:

1. converting data types, then = inquiry;  

  select * from bank where cast(rate as char) = 0.5;

2. Use fuzzy matching like;

  select * from bank where rate like '0.5';

 

Content Reference blog: https: //blog.csdn.net/czh500/article/details/86170499

Guess you like

Origin www.cnblogs.com/liaoliao51/p/12161633.html