MS SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMS SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
1200+ fellow developers rate and compare features of the top IDEs, like Visual Studio, Eclipse, RAD, Delphi and others, across 13 categories. Enjoy this FREE Download of the IDE User Satisfaction Study by Evans Data Corporation. Download Now!
  #1  
Old June 16th, 2004, 04:33 PM
nuLime nuLime is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Location: US
Posts: 90 nuLime User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 48 m 48 sec
Reputation Power: 5
Question Please help with IF statement

I am trying to execute an IF statement in MySQL (something I rarely do) but I keep receiving the error:
"Invalid Query: 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 SELECT "...rest of statement.

I am using the following SQL statement executed by PHP's mysql_query() function:
"IF SELECT something FROM my_table WHERE something='4935' AND whatever='N' THEN INSERT INTO my_table (something,next_thing,whatever) VALUES('4935','some text','N') ELSE INSERT INTO my_table (something,next_thing) VALUES('4935','some text') END IF"

Any ideas what might be wrong?

Thanks!

MySQL verion 4.0.18 with PHP 4.3.6.

Reply With Quote
  #2  
Old June 16th, 2004, 05:16 PM
swampBoogie swampBoogie is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Jan 2003
Location: Paris Uppland
Posts: 1,766 swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 2 Weeks 4 Days 6 h 24 m 8 sec
Reputation Power: 37
Quote:
I am trying to execute an IF statement in MySQL


Why post Mysql questions in a SQL server forum?

Mysql does not support if statements in version 4.

Reply With Quote
  #3  
Old June 16th, 2004, 05:51 PM
nuLime nuLime is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Location: US
Posts: 90 nuLime User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 48 m 48 sec
Reputation Power: 5
Ahhh...that explains that.


For some reason I thought the forum said MySQL not MS SQL.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMS SQL Development > Please help with IF statement


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway