June 3, 2020
Now that we have talked about how to specify what columns we would like to see in a view, we can talk about how to control the records or rows. The WHERE clause is a very useful one and it allows us to only view records that fit a certain criterion. The criteria often times involves some sort of logic or a conditional statement following it. For the purpose of this tutorial we will use very simple logic although you can get very particular and use some complicated conditions to achieve exactly what you are looking for.
An important thing to note when writing SQL queries is the order in which you are writing the clauses. You may have noticed in the last tutorial the from clause came after the select clause. SQL has a bit of an intuitive way of working, think of it by saying “Lets look at these columns, from this table” but boiling that down into a very concise syntax that a computer can understand. Now we are adding one more clause to the mix; the WHERE clause occurs after the from statement, think “Lets look at these columns, from this table, where I can only see transactions that are more than 100 dollars” Let’s look at an example that accomplishes this train of thought.
Click here for Part 3: GROUP BY statement