Re: If Column Exists

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

 



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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux