An example of using multiple conditions of if else in mysql
This article mainly introduces the use of mysql if else multi-condition examples, the article is very detailed, has a certain reference value, interested friends must read it!
1. Write a update statement to increase commodity prices. The specific rules are as follows
Within 99 yuan, the price will be increased by 20%.
2. Between 100 and 999 yuan, the price will be increased by 10%
Between 1000 and 1999, the price will be increased by 5%.
4. Other price increases by 2%
Update goods set price = (case when price between 0 and 99 then price * 1.2 when price between 100 and 999 then price * 1.1 when price between 1000 and 1999 then price * 1.05 when price > 1999 then price * 1.02 end); select * from goods
2. Write a select statement to achieve the following effect
Student number, name, score grade-1 Zhang San 86 good 2 Li Si 98 excellent 3 Wang Wu 72 pass 4 that six 69 pass 5 Primary one 56 fail
The rules are as follows:
1, > = 90: excellent
2, > = 80: good
3, > = 60: pass
4. = 90 then 'excellent' when score > = 80 and score
< 90 then '良好' when score >= 60 and score < 80 then 'pass' when score < 60 then 'fail' end) as level from scores; or above is all the contents of this article entitled "examples of Multi-conditional use of if else in mysql". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!