Jump to content

Comparing with column type 'decimal'.


haku

Recommended Posts

I have a table with a column type 'decimal'. The table is called 'uc_product', and the column is 'sell_price'. There are two rows:

 

row 1: sell_price = 25.00000

row 2: sell_price = 22.55000

 

The following query is returning both rows, though I am of the belief that it should only be returning the first row:

 

SELECT n.nid FROM node AS n JOIN uc_products AS up WHERE n.type = "product" AND up.sell_price >= 25 AND up.sell_price <= 30

 

I've not worked with columns type decimal before, so this one is throwing me for a loop. I've tried passing in values of 25.00 and 30.00, but I still get back the same two rows. Does anybody have any idea on where I'm going wrong here?

Link to comment
https://forums.phpfreaks.com/topic/194723-comparing-with-column-type-decimal/
Share on other sites

So now I've tried this query:

 

SELECT n.nid, up.sell_price

FROM node AS n

JOIN uc_products AS up

WHERE n.type = "product"

AND up.sell_price =25

 

And it returns two rows:

row  nid  sell_price

1    19  25.00000

2    20  25.00000

 

I have no idea why it is returning a value of 25.0000 for the sell price where nid is 20 - the value in the column is 22.55000.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.