Unix Technical Forum

Question about INFORMATION_SCHEMA

This is a discussion on Question about INFORMATION_SCHEMA within the MySQL forums, part of the Database Server Software category; --> What is wrong with this statement ? IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'creature_template' AND ...


Go Back   Unix Technical Forum > Database Server Software > MySQL

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-28-2008, 11:30 AM
Poster
 
Posts: n/a
Default Question about INFORMATION_SCHEMA

What is wrong with this statement ?

IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME =
'creature_template' AND COLUMN_NAME = 'solo') THEN
ALTER TABLE creature_template ADD COLUMN solo INTEGER(1) DEFAULT 0;
END IF;

This is the error message:
/* Error: "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 =
'crea' at line 1" */

This is 5.0.45 on Windows.
Thanks.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-28-2008, 11:30 AM
Paul Lautman
 
Posts: n/a
Default Re: Question about INFORMATION_SCHEMA

Poster wrote:
> What is wrong with this statement ?
>
> IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE
> TABLE_NAME = 'creature_template' AND COLUMN_NAME = 'solo') THEN
> ALTER TABLE creature_template ADD COLUMN solo INTEGER(1) DEFAULT 0;
> END IF;
>
> This is the error message:
> /* Error: "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 = 'crea' at line 1" */
>
> This is 5.0.45 on Windows.
> Thanks.


IF NOT EXISTS is only valid SQL as part of a CREATE statement.


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 06:08 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com