getting float values from mysql table

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dannymc1983
Forum Commoner
Posts: 80
Joined: Wed Feb 16, 2005 7:24 am

getting float values from mysql table

Post by dannymc1983 »

i have one fields stored in table of type float(3,2). this stores float values like 2.99. but what i cant understand is that if i try to select the row with the value 2.99 using this piece of SQL code for example:

Code: Select all

select * from table where value = '2.99'
it returns nothing, even though i know that 2.99 is one of the fields in the table. anyone know why this is?? and what i can do to correct it...
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

i think you need to do this

Code: Select all

select * from tablename1 where round(test, 2) = round(2.99, 2)
dannymc1983
Forum Commoner
Posts: 80
Joined: Wed Feb 16, 2005 7:24 am

Post by dannymc1983 »

thanks, that worked!
Post Reply