I have a decimal field in the database which I try to query. The field is used for all sort of numbers so it could be a currency with 2 digits or a anything else with a different format. The field is set up as decimal(15,5).
So a currency could be saved in there like 4.99000 and I format it when I read it out according to a set up which is saved in another table which will tell me the decimal-places and the decimal-separator. All that is fine, but how would I query something like that? Because "WHERE field = 4.99" will obviously not return this record. Any suggestions what I could do?
UPDATE:
OK, I have to go a slight different way. I take the entered number and use explode to split it into an array. I know that after the decimal . I have 5 numbers so as a next step I use
$numericValue = explode($myFormat['decimalseparator'], $value) // could be a . or a ,
$newValue = str_pad($numericValue[1], 5, "0", STR_PAD_RIGHT) ;
$dbValue = $numericValue[0].'.'.$numericValue[1];
It does seem to work, but I do wonder if I oversee something here...
will obviously not return this recorddid you try? it the datatype of the table column supports decimal that will work