Problem with data type

They have: 5 posts

Joined: Sep 2006

Hi

I recive data in the following format
BMW M3 black on Business Plan 320 with 50 miles for £800.00

The data is all stored in a text field, I take the price out at the end of the field and usine the Instr and right function. which is done correctly but the i want to use the price in a calculation and it wont work, please can you tell me what is the best way to do this?

Greg K's picture

He has: 2,145 posts

Joined: Nov 2003

I just made a test table, with one field `desc` and put your line in it. I then execute the following:

SELECT (substring(`desc`,instr(`desc`,'£')+1)*4) as VAR1 FROM `test`'

and the result back from mySQL is 3200, which is correct. Can you give an example of how you are trying to do it.

-Greg

They have: 83 posts

Joined: Nov 2007

Convert the price to integer. now it will be string

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.