haku Posted March 10, 2010 Share Posted March 10, 2010 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? Quote Link to comment https://forums.phpfreaks.com/topic/194723-comparing-with-column-type-decimal/ Share on other sites More sharing options...
haku Posted March 10, 2010 Author Share Posted March 10, 2010 To add to this, I've just tried CAST('25.0000' AS DECIMAL) but even this doesn't solve the problem. Quote Link to comment https://forums.phpfreaks.com/topic/194723-comparing-with-column-type-decimal/#findComment-1024022 Share on other sites More sharing options...
haku Posted March 10, 2010 Author Share Posted March 10, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/194723-comparing-with-column-type-decimal/#findComment-1024032 Share on other sites More sharing options...
haku Posted March 10, 2010 Author Share Posted March 10, 2010 I figured it out. A stray semi-colon in my code was preventing the concatenation of the 'on' statement. I was having a blind moment. Quote Link to comment https://forums.phpfreaks.com/topic/194723-comparing-with-column-type-decimal/#findComment-1024082 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.