May 2020
Beginner
564 pages
14h 9m
English
The IF and CASE statements are similar but do have some differences, as outlined in the following table:
| IF | CASE |
| Accepts three parameters | Accepts multiple parameters |
| Accepts one condition | Accepts multiple conditions |
The following shows the syntax of IF:
IF(condition, value if true, value if false);
Here's an example of an IF statement that will return 'barely any' for g_all between 0 and 10, and 'some more' for any games not between 0 and 10 instead of the number value that is in the column:
USE lahmansbaseballdb;SELECT playerid, yearid,IF(g_all between 0 and 10, 'barely any', 'some more') as gamecountFROM appearancesWHERE yearid = 1990;
Read now
Unlock full access