Marco Antonio Marco Antonio - 8 months ago 67
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;


you can calc with IF like this:

update tbBook
set tbBook.priceBook = tbBook.priceBook * IF( tbBook.priceBook <= 20 , 1.20, 1.15);