I don't think MySQL can do that....maybe with some kind of stored procedure....
If you're using 5.0 or higher, use the INFORMATION SCHEMA to find out
if the column exists. If not, use the "show create table" statement
and parse it.
Why is this a problem, though? (just curious, I'm not sure this would
ever come up. I don't do automatic schema changes, always do them
manually, so I'm not too sure why you'd be amiss....unless you're
running gobs of servers and some of them have the column and some of
them don't.....but even then you could run a script that alters the
table to add the column and just let it thrown an error if it already
exists.)
-Sheeri
On 5/24/06, Daevid Vincent <daevid@stripped> wrote:
> I want to do something like this:
>
> if not exists `hotel_page_templates`.`hpt_custom_fields`
> alter table `hotel_page_templates` add column `hpt_custom_fields` text after
> `hpt_alternate_username`;
>
>
> ÐÆ5ÏÐ
>
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe: http://lists.mysql.com/mysql?unsub=1
>
>