You want to write a query. You want to use a subquery in that query. You don’t want to type so much.
What to do?
Enter the Query Builder.
It’s been part of your worksheet for years.
Click on it.
Drag a table into it.
But I don’t want to see the department_id in the output of my query, so uncheck it in the ‘Output’ column down below.
Now right click in its corresponding Criteria box.
Now look ‘up’ – you’ll see there’s a new tab/panel.
Now we have a new query builder of sorts. I’m going to drag over the DEPARTMENTS table.
I’m only going to bring back the DEPARTMENT_ID – because that’s why my main query expects to fulfill the predicate clause.
And now I’ll also add the DEPARTMENT_NAME, but unchecking the ‘Output’ column again, and add a WHERE clause there. I I only want to return departments that don’t have a name with the text ‘SALES’ in them – no offense folks!
Let’s go look at our generated code and run the query.
The Query Builder is also useful for generating JOINS
Go read/watch this.