Jump to content

price format in database


techker

Recommended Posts

Hey guys im doing a new dealership site for my buddy .he already has an older script that inserts prices like 15,000

 

now in my new site i want to make ranges of prices

 

like >= to or <= to...

 

so it is working but half way..

 

my code

 

 SELECT * FROM  `cars` WHERE  `Retail_price` >= 15.000LIMIT 0 , 30  
 
it works but it also shows cars that do not have a ,
 
like 900 or 500....
 
i put the . cause in the database there is a ,
 
is there a way arround this?
 
and what would be the best format?
 
no . just 15000 or 15.000
Link to comment
https://forums.phpfreaks.com/topic/282785-price-format-in-database/
Share on other sites

it doesn't work if i only put 15000

 

I meant you need to change the data in the database, not your query.

 

1. What is the column type of Retail_price?

2. Why is there a comma? Is it a thousands separator or a decimal?

Reatail_price

 

ya its a thousand separator..

 

ok i guess i will..so no decimal or comma's right just plain numeric

 

Well it depends.  If you are storing prices then you could pick the DECIMAL column type to store 15000.99 for example because the decimal is part of the data (it separates the whole number from the fractional) and can't really be calculated from a string of numbers like 1500099.  The comma as a thousands separator is only format and can be added when displayed because you can consistently determine where to place the commas.

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.