ON Clause & Cross Join We use different joins to pull the records from multiple tables. We need to use the ON clause along with JOIN. What will happen if we don't use the ON clause? MS-SQL Server If we don't mention the ON clause, it throws an error. However, if we use the same column from the same table on both sides, it works as a cross-join. Also, if you mention condition as 1=1 in the ON clause, it treats as CROSS JOIN. However, in Snowflake, both above queries will work. Apart from this, if you don't mention the ON clause, it treats it as CROSS JOIN: Yogesh Shinde LinkedInProfile <<< Back Next >>>
UNION By Name Sometimes, we have to combine data from multiple tables. In this case, we can use UNION. However, the catch is that the order of the columns should be the same. MS-SQL Server We can achieve this by using UNION as below: In Snowflake, we can use the same query as above; however, we have to use the same column order in the select clause. However, we can use UNION BY Name as below. The order of the columns in the select clause does not matter. NOTE: Similarly, you can use UNION ALL BY NAME . For more details, you can refer to the following: UNION . Yogesh Shinde LinkedInProfile <<< Back Next >>>
Multi Table Insert We insert data into a table, and sometimes, we must archive/back it up in another table. MS-SQL Server We can achieve this by using magic or virtual tables present, like INSERTED, as below: However, in Snowflake, the insert statement has an additional clause, INSERT ALL, which allows you to insert into multiple tables: For more details, you can refer to the following: Multi_Table_Insert . Yogesh Shinde LinkedInProfile <<< Back Next >>>
Comments
Post a Comment