If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > select a rounded float field

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-18-09, 11:35
sakis sakis is offline
Registered User
 
Join Date: Nov 2009
Posts: 19
select a rounded float field

Hi

i am creating a price searching widget.

the price table has the fields
price , product_id


Sometimes the price is a long float for example 4,56889
I d like to return also this product_id when the user searches for 4,57.

so i need a where clause in which i can round the db price field.

I used "WHERE ROUND(price,2) =4,57" but it does not rounding the price.

Is there a way to do that ?
Reply With Quote
  #2 (permalink)  
Old 11-18-09, 11:47
healdem healdem is offline
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,250
Code:
select my, column, list, ROUND(price,2) as RPrice from MyTable
where round(Price,2)  = 4.57;
seems to work for me
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On