Re: RE: [PHP] If Column Exists

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



SHOW COLUMNS FROM tablename;

Also check http://dev.mysql.com/doc/refman/5.0/en/

On Wed, Aug 13, 2008 at 3:02 PM, Simcha <simcha@xxxxxxxxxxxx> wrote:
> You can try 'select `testcol` from `table`' and then check if you got a
> mysql_error().
>
>
>
> -----Original Message-----
> From: Robin Vickery [mailto:robinv@xxxxxxxxx]
> Sent: Wednesday, August 13, 2008 10:33 AM
> To: php List
> Subject: Re: [PHP] If Column Exists
>
> 2008/8/12 VamVan <vamseevan@xxxxxxxxx>:
>> Hello,
>>
>> I am working on data migration for one mysql db to another using PHP. How
> do
>> I check if a particular table has a particular column. If not alter...
>>
>> Thanks
>>
>
> Use the information_schema:
>
> SELECT COUNT(*) AS column_exists FROM information_schema.COLUMNS WHERE
> TABLE_SCHEMA='db_name' AND TABLE_NAME='table_name' AND
> COLUMN_NAME='column_name';
>
> -robin
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
> No virus found in this incoming message.
> Checked by AVG - http://www.avg.com
> Version: 8.0.138 / Virus Database: 270.6.2/1609 - Release Date: 13/08/2008
> 06:43
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux