drisate Posted February 10, 2010 Share Posted February 10, 2010 Hey guys! I need to check if a columns exist before permorming a table alteration, This is what i got so fare: IF NOT EXISTS ( SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = `page` AND COLUMN_NAME = `aaa` ) BEGIN ALTER TABLE `page` ADD `aaa` LONGTEXT NOT NULL END The MySQL error it returns is: #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IF NOT EXISTS ( SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = `pag' at line 1 Quote Link to comment Share on other sites More sharing options...
fenway Posted February 16, 2010 Share Posted February 16, 2010 Well, you can't start with IF... but why bother? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.