Thursday, May 14, 2020

How to make LEFT JOIN depend on a further INNER JOIN - ( Filtering a left join further )



Below is how to make LEFT JOIN depend further on an INNER JOIN. Below is an example of "using LEFT JOIN and INNER JOIN in the same query":

SELECT *
FROM TableFoo tf1
LEFT JOIN (TableBar tb1
  INNER JOIN TableBaz tb2 ON tb2.id = tb1.baz_id
) ON
  tb1.id = tf1.bar_id


In this example, tb1 will only be included if tb2 is also found.

Recently Executed queries

 SELECT     txt.TEXT AS [SQL Statement],     qs.EXECUTION_COUNT [No. Times Executed],     qs.LAST_EXECUTION_TIME AS [Last Time Executed],   ...