Another form of UPDATE?

Asked

Viewed 47 times

2

I am doing a Mysql class work and would like to know another form of UPDATE, because this is not changing.

Update the price of service of all animals that received bath in the pet shop and had less than 15 real value.


UPDATE `aula_sub_query`.`servico_prestado` 
    SET `preco` = 25.00
    WHERE `cod_SERVICO_PRESTADO` = 1 AND `preco` < 25.00;

  • 1

    Ideally in these cases, you can also post your table structures so that we can help you better.

1 answer

5

Andrews, assuming that the service code provided for Bath in the PET SHOP, is 1, as you are using in the WHERE, just correct the value of your condition.

Instead of using

UPDATE aula_sub_query.servico_prestado SET preco = 25.00
WHERE cod_SERVICO_PRESTADO = 1 AND preco < 25.00;

Utilize

UPDATE aula_sub_query.servico_prestado SET preco = 25.00
WHERE cod_SERVICO_PRESTADO = 1 AND preco < 15;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.