0

I am using the following query, it is showing the empty result but the record exist in table. Please let me know how can do it

select * from wp_rg_lead_detail where lead_id=5047 and field_number=1.6
select * from wp_rg_lead_detail where lead_id=5047 and field_number=1.6

in both case query return the empty result.but data exist in table.

data type of the field_number is float in database.

Paolo Stefan
  • 10,112
  • 5
  • 45
  • 64
user1734190
  • 157
  • 1
  • 2
  • 12
  • You shouldn't compare floats for equality: have a look at for example http://stackoverflow.com/questions/8839460/why-doesnt-this-sql-query-return-any-results-comparing-floating-point-numbers – Arno Mittelbach Aug 18 '13 at 17:43
  • but I have mix value eg. 2,3, 1.3,1.6.8.1,8.5,8.6 I wanna values regarding this from the database, if I use >= and <= equal then it will return the multiple results not corresponding the field_number as 1.3 or 1.6 – user1734190 Aug 18 '13 at 18:01

1 Answers1

1

Change the column to to decimal or numeric,they store exact numeric data values.Floats are always approximative numbers(in the way that are stored)

EDIT:Try it like this

select * from wp_rg_lead_detail where lead_id=5047 and format(field_number,1)=1.6
Mihai
  • 26,325
  • 7
  • 66
  • 81
  • but in table I have both value for example 2 , 4, 1.3,1.6 I am using the gravity form so it is the id of the subfields. – user1734190 Aug 18 '13 at 17:48