MySQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMySQL Help

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:
  #1  
Old July 4th, 2000, 04:21 PM
weldonj weldonj is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2000
Posts: 41 weldonj User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 47 m 2 sec
Reputation Power: 8
Can you do If/Then statements in Mysql? If so a little help would be appreciated (a brief example). Basically, I want to create a new variable with a certain value depending on the relationship between two other variables.

If you can't do this, I'm sure there is some way around this using queries. Is this the case?

Thanks

Reply With Quote
  #2  
Old July 5th, 2000, 12:12 PM
rod k rod k is offline
Apprentice Deity
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jul 1999
Location: Niagara Falls (On the wrong side of the gorge)
Posts: 3,237 rod k User rank is Private First Class (20 - 50 Reputation Level)rod k User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 m 8 sec
Reputation Power: 13
Send a message via AIM to rod k
IF (expr1,expr2,expr3)

Returns expr2 if expr1 is true, else returns expr3

so your select would look like:

select IF(some_field=something,'True','False') as somename where foo;

That's as specific as I can get from your description.

Reply With Quote
  #3  
Old July 5th, 2000, 01:09 PM
weldonj weldonj is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2000
Posts: 41 weldonj User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 47 m 2 sec
Reputation Power: 8
Thanks for the help, I'll try and be more specefic, because I don't clearly understand your reply especially the "somename where foo;" part:

Say I have a persons answers to a question, ANSWER1, and then I also have the correct answer, call it field CANSWER1. So I want to be able to assign points to another field POINTS depending on whether the answer is correct. I want to update this POINTS field for all of the questions I have. Does this make since?

Thanks again.

<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by rod k:
IF (expr1,expr2,expr3)

Returns expr2 if expr1 is true, else returns expr3

so your select would look like:

select IF(some_field=something,'True','False') as somename where foo;

That's as specific as I can get from your description.
[/quote]


Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMySQL Help > IF/THEN


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 4 hosted by Hostway
Stay green...Green IT