0

I want to do this select, but always return NULL:

SELECT * FROM world.country c WHERE c.LifeExpectancy IN (45.2,46.2)

When I do separate selects, works fine:

select * from world.country c where c.LifeExpectancy IN (45.2)

select * from world.country c where c.LifeExpectancy IN (46.2)

Anyone know what is going on here?

Martin
  • 22,212
  • 11
  • 70
  • 132
Filipe
  • 1
  • What type of data is in column `LifeExpectancy`? Using floating numbers is unwise as they're er, floating, and non-specific. You should be using **DECIMAL** and **CAST**ing the number to a decimal type so both values are the same type. – Martin Aug 26 '22 at 12:38
  • LifeExpectancy is float(3,1). – Filipe Aug 26 '22 at 12:45
  • Right, change your float column to `Decimal` data type. – Martin Aug 26 '22 at 12:45
  • See also https://stackoverflow.com/questions/40594333/mysql-compare-float-numbers-ignored – Barry Carter Aug 26 '22 at 12:49

0 Answers0