From the course: Intermediate SQL: Data Reporting and Analysis
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Automating your query creation - SQL Tutorial
From the course: Intermediate SQL: Data Reporting and Analysis
Automating your query creation
- [Instructor] What if you need to run a hundred update queries, all with slightly different values or filters? If the thought of doing your task manually fills you with dread, consider automating your query creation. I tend to use Excel for this, and I'm going to show you how I do it. Now, you can run multiple update queries by separating them with semicolons. Let's just show you. UPDATE film, SET title to be abc, WHERE the film_id is 1, semicolon. And then we're going to copy that, pop it down, and say 2. UPDATE, everything stays the same, but I want to update title to be def, WHERE film_id is 2. Okay? So this is our target output, is to create these multiple scripts. And it might seem obvious 'cause this is more about Excel than anything, but I wanted to show you because I do this regularly, and I think it's useful. So here is our spreadsheet, and we just break the query up into static and variable parts.…
Contents
-
-
-
-
-
UPDATE fields in a table6m 11s
-
(Locked)
Common issues with the UPDATE command7m 53s
-
(Locked)
Automating your query creation3m 52s
-
(Locked)
Updating a field using JOIN1m 47s
-
(Locked)
Updating dynamically8m 29s
-
(Locked)
Challenge: Update the film table using JOIN44s
-
(Locked)
Solution: Update the film table using JOIN2m 52s
-
-
-
-