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.
Hey Jeff, is there a way to run the subquery in the Query builder, as opposed to having to run the entire query? I often find myself in situations with several levels of nesting, and it’s a little tricky to find out where the error is sometimes.
No…but you could switch out of the QB to the worksheet and highlight what you want to run.
Jeff. I don’t know what to say. Did you write this? It doesn’t seem to work the way it is written?
Indeed I did.
Where did you get off track? Or did I get off track perhaps…
I’m sorry. It has been a long day. Let me try it again in the morning.