mysql float data not selecting in where clause

后端 未结 5 1651
清酒与你
清酒与你 2020-12-16 20:18

This maybe an easy one but i couldn\'t get answer. I need to select float value from table

example table :-

value
10.2
4.5
4.6
4.06
<
5条回答
  •  生来不讨喜
    2020-12-16 20:51

    Generally, you should never check equality with floats (unless, potentially, you have the same object). Internally, it is represented with more precision, even if it isn't showing it to you by the time it outputs to the screen. This basic tenet holds true for computing in general.

    There are a dozens of schemes for doing this, but here is a simple one, which should make sense:

    SELECT * FROM table where value BETWEEN 4.599 AND 4.601
    

提交回复
热议问题