You are here: Re: Converting column types ( MySQL) « PHP SQL « IT news, forums, messages
Re: Converting column types ( MySQL)

Posted by Mick White on 10/07/05 18:41

Steve wrote:

>>I have a column `cover` VARCHAR(10) that lists a cover charge in the
>>form of "$x.00", where x is the price of admission. I'd like to convert
>>the column to INT UNSIGNED, so that x(a number) is listed, not "$x.00".
>>Is this possible?
>>Thousands of entries are involved.
>
>
> First create a new column, say `cover_int` as INT UNSIGNED
>
> Then execute this:
>
> UPDATE `mytable`
> SET `cover_int` =
> CONVERT(SUBSTRING(`cover`,2,LENGTH(`cover`)-1),UNSIGNED)
>
> Confirm that the new column looks correct, then drop (or rename) the
> old column and rename the new one to `cover`.

That did the trick, Steve. Thanks.
Mick

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация