简体   繁体   中英

Oracle sql updating multiple rows

I have a table name "Table1" and I want to update John's last name which is spelled incorrectly as Do and it needs to be Doe.

Table1 currently has 65 rows of John Do, will this work? This table is in active use by an application.

UPDATE
TABLE1
SET LASTNAME = 'DOE'
WHERE LASTNAME LIKE '%DO%'

Yes, all entries that have the LASTNAME containing 'DO' will be updated to 'DOE'

If you want to make sure you don't update anything else, I suggest changing your query to:

UPDATE
TABLE1
SET LASTNAME = 'DOE'
WHERE LASTNAME = 'DO' AND FIRSTNAME = 'John'

Note that the strings are case sensitive, so you should probably change 'DO' to 'Do'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM