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

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