Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

SQL Joins and Where clauses

Number4
8 - Asteroid

I've not taken any classes on SQL, just learned hands on.  I was trying to fix a query for someone and they had written their Joins in a fashion I was not used to.

For example, I write ALL of my Join statements then put one Where with Ands at the very end.

 

This individual had placed some Where clauses in a couple of the joins.  And these "where" clauses as I see, would normally just be below at the end of all the Joins.

 

So does SQL Developer read the Where/ands as it does each Join above?  Or is it more efficient to put Where's below each Join?

2 REPLIES 2
echuong1
Alteryx Alumni (Retired)

Are you looking to replicate the joins and where clause in Designer, or is this a general SQL syntax question? In Alteryx, I recommend having the where clauses embedded into the input. From there, you will be joining only a subset of the records and will make processing more efficient.

 

With regard to SQL syntax, something like Stackoverflow may be a more appropriate place for your question.

https://stackoverflow.com/questions/354070/sql-join-where-clause-vs-on-clause

https://stackoverflow.com/questions/15483808/sql-join-where-to-place-the-where-condition 

 

Hope this helps!

Number4
8 - Asteroid

Thanks.  I was searching the web for a SQL answer, but answers are always scattered and on this, nothing hit.


Your second link was helpful on the SQL side.

 

This persons answer, hopefully correct, is what I was looking for:

 

"I think the faster way is to put the filter in the where clause, because it will procees that filter in the where first , and then the join clause, so there will be no need of permutation of filters." - Artemination

 

I use a lot of SQL statements to bring in data.

Labels