Re: If Column Exists

From: Date: Sun, 17 Aug 2008 12:31:40 +0000
Subject: Re: If Column Exists
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-278239@lists.php.net to get a copy of this message
There is IF EXISTS for tables, is there the same thing for columns in the table like IF EXISTS column IN TABLE table ? Just an idea 2008/8/13 VamVan <vamseevan@gmail.com> > Interesting. Thanks guys!! > > On Wed, Aug 13, 2008 at 1:32 AM, Robin Vickery <robinv@gmail.com> wrote: > > > 2008/8/12 VamVan <vamseevan@gmail.com>: > > > 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 > > > > > -- Luke Slater

« previous php.general (#278239) next »