Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

An example of using multiple conditions of if else in mysql

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 233

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report