Hi,


2005/9/26, Peter Brawley <[EMAIL PROTECTED]>:
> Claire,
>
>  >I want to check if a column exists in a table before I
>  >do an alter table to add it. How do I do this in
>  >mysql? Thanks.

other solution, do your query in all case and check for the return
error (if any).
mysql> alter table board add message varchar(255) not null default '';
ERROR 1060 (42S21): Duplicate column name 'message'

So, if you get back that error, the column already exists. So if it
exists the table is left untouched, otherwise it does what you want.
(yeah, Information_schema would be better, but 5.0 is in gamma)

--
Pooly
Webzine Rock : http://www.w-fenec.org/

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to