• Our friends from AlphaCentauri2.info are in need of technical assistance. If you have experience with the LAMP stack and some hours to spare, please help them out and post here.

Help: How to use if/then/else with SQL

crawf0rd

The One and Only
Joined
Jan 30, 2012
Messages
483
I can't for the life of me figure out how to make a working if/then/else statement.

I'm trying to make one that would work like this:
Code:
IF NumOfApples = 5 WHERE Type = AppleBasket THEN NumOfOranges = 2 WHERE Type = OrangeBasket ELSE NumOfOranges = 3 WHERE Type = OrangeBasket
I hope the example isn't too confusing, if it is I can supply my attempt at it.
Also, maybe this goes in an sql-centric forum? I didn't know, and I knew you guys knew your stuff.
Any help would be appreciated.
 
Simple answer is ... SQL is a langauge for database manipulation, not programming, so there are no if/then/else type forms

Complex answer is ... in some circumstances you can achieve similiar effects with UPDATE, SELECT and UNION

It would be easier with a "real life" example, (as you've omitted key table name information from your pseudo-code)
 
Back
Top Bottom