Marco Antonio Marco Antonio - 14 days ago 5
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

you can calc with IF like this:

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