Lesson 50. Setting Up Queries For Ablation Testing
Sometimes you write a complex SQL statement that doesn’t work, and you do not know why. The best way to figure out what is wrong is by ablation testing.
Ablation testing is where you turn things off until you isolate the problem. In the case of SQL queries, this involves commenting out lines of a complex WHERE clause (or JOIN) until you find the thing that is not working as designed.
However, if your WHERE clause starts with a filter, you have to move it so you can comment it out. If you start your WHERE clause with 1 = 1, which is always true, then you preserve syntax and can easily comment out your filters without having to rewrite your code.
No matter how simple your SQL statement is, I recommend that you get in the habit of creating ablation testing ready SQL statements.
Examples
Basic Setup
In [ ]:
An Example Of Ablation Testing
Here we suspect that two lines in the WHERE clause are causing our query to act up.
In [ ]:
Last updated