|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
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. |
|
#3
|
|||
|
|||
|
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] |
![]() |
| Viewing: Dev Shed Forums > Databases > MySQL Help > IF/THEN |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|