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
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.