JOIN (SELECT … ) ue ON 1=1?

前端 未结 4 1982
野的像风
野的像风 2020-12-15 04:59

I am reading an SQL query in Redshift and can\'t understand the last part:

...
LEFT JOIN (SELECT MIN(modified) AS first_modified FROM user) ue
ON 1=1
         


        
4条回答
  •  醉梦人生
    2020-12-15 05:26

    It's simply doing a cross join, which selects all rows from the first table and all rows from the second table and shows as cartesian product, i.e. with all possibilities.

    JOIN (LEFT, INNER, RIGHT, etc.) statements normally require an 'ON ..." condition. Putting in 1=1 is like saying "1=1 is always true, do don't eliminate anything".

提交回复
热议问题