techker Posted October 7, 2013 Share Posted October 7, 2013 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 Quote Link to comment Share on other sites More sharing options...
AbraCadaver Posted October 7, 2013 Share Posted October 7, 2013 If the 15,000 is supposed to be fifteen thousand then do not store it withe the comma. Just put data in the database, no formatting. Quote Link to comment Share on other sites More sharing options...
techker Posted October 7, 2013 Author Share Posted October 7, 2013 it doesn't work if i only put 15000 Quote Link to comment Share on other sites More sharing options...
AbraCadaver Posted October 7, 2013 Share Posted October 7, 2013 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? Quote Link to comment Share on other sites More sharing options...
techker Posted October 7, 2013 Author Share Posted October 7, 2013 Reatail_price ya its a thousand separator.. ok i guess i will..so no decimal or comma's right just plain numeric Quote Link to comment Share on other sites More sharing options...
AbraCadaver Posted October 7, 2013 Share Posted October 7, 2013 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. Quote Link to comment Share on other sites More sharing options...
techker Posted October 7, 2013 Author Share Posted October 7, 2013 ok great.thx for the help Quote Link to comment 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.