Marco Antonio Marco Antonio - 1 year ago 94
MySQL Question

Exercise MUlti update

Help with that
the exercise plss. "Give a 20% increase to all books that cost up to $ 20 and an increase of 15% For those who cost more than $ 20.00." I just don't know what to do with that exercise. How do I give a raise for those who cost more than 20?

update tbBook
set tbBook.priceBook = (tbBook.priceBook*1.20)
where tbBook.priceBook <= 20;

Answer Source

you can calc with IF like this:

update tbBook
set tbBook.priceBook = tbBook.priceBook * IF( tbBook.priceBook <= 20 , 1.20, 1.15);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download