Check for equality on a MySQL Float field

后端 未结 5 1638
失恋的感觉
失恋的感觉 2021-02-12 16:00

I have a Joomla system and I\'m trying to change the search so that it correctly finds floating point values in the database.

So, I have a query that is built at runtime

5条回答
  •  南方客
    南方客 (楼主)
    2021-02-12 16:26

    I found a way to check for what my users view as equality.

    I had to convert the field to a character string and test the character sets, so this works fine for them:

    select 'column1'
    from 'some_table'
    where CAST('some_float_field' AS CHAR) <=> '2.18'
    

提交回复
热议问题