If you are here, you are surely looking to remember the syntax of the SQL Update statement or to see quick and practical examples that will help you with your learning. Both for one and for the other I will leave below several examples of UPDATE SQL.
- UPDATE SQL example 1
- 2nd Example UPDATE SQL
- 3rd Example of UPDATE in SQL
- Conclusion on the UPDATE SQL examples
UPDATE SQL example 1
SQL UPDATE Example that updates the title and publisher fields of a table book. The following example is so simple that it doesn’t even use the WHERE statement to filter the records in the table.
UPDATE libro SET titulo = 'ejemplos de sql update', editorial = 'srcodigofuente';
2nd Example UPDATE SQL
Query that updates the qualification and editorial of the table book just for the record with id 33:
UPDATE libro SET titulo = 'ejemplo update', editorial = 'sql srcodigo' WHERE id = 33;
This last example is very similar to the first but adding filtering using WHERE SQL to update only the chosen record.
3rd Example of UPDATE in SQL
Now I’m going to add a bit more complexity with a double condition and using the LIKE operator.
To be exact, in the following query I am going to perform the same task as example of previous update but with the condition that the books have to contain in the column theme the word “examples”. and the language is “Spanish” Also, this time the table will be called examples_sql_ebook
UPDATE ejemplos_sql_ebook SET titulo = 'ejemplos de update en sql', editorial = 'srcodigofuente.com' WHERE tematica LIKE '%ejemplos%' AND idioma = 'español';
Conclusion on the UPDATE SQL examples
What do you think of the examples that I have shown you? Have you found them useful? I really hope so, if so, I would appreciate it if you shared this content with other interested parties.
If you think this article deserves more examples, feel free to leave me a comment below with your request or an example of your own. Thank you!