How to do Update on 3 rows in a query

1

How can I make an update to change the value of 3 lines?

I have a similar structure:

Id |             Nome                   | Ordinal
13 | Juizado Especial Cível             |    ª
14 | Juizado Especial Criminal          |    ª
15 | Juizado Especial Cível e Criminal  |    ª

I need to change the ordinal from 'ª' to 'º' of ids 13, 14 and 15 in a single query, instead of making an update for each id.

How do I?

Thank you very much.

    
asked by anonymous 05.02.2018 / 13:41

2 answers

3

Simple use the update with WHERE with as many conditions as are necessary using relational operators in this case OR

UPDATE table1 SET Ordinal = 'º' WHERE id = 13 OR id = 14 OR 15

Or use the IN that follows in the same rationale:

UPDATE table1 SET Ordinal = 'º' WHERE id IN (13,14,15)
    
05.02.2018 / 13:48
2

Headers

use in () in your where clause, eg

UPDATE table1 SET Ordinal = 'º' WHERE id IN (13,14,15),

Ref: link

    
05.02.2018 / 13:59