开发者

Teradata equivalent of MySQL's USING

开发者 https://www.devze.com 2023-02-10 03:53 出处:网络
My question is quite similar t开发者_StackOverflowo this one, but in Teradata: SQL Server equivalent of MySQL's USING

My question is quite similar t开发者_StackOverflowo this one, but in Teradata:

SQL Server equivalent of MySQL's USING

Is there any equivalent shortcut to this query?

SELECT * 
  FROM t1 
  JOIN t2 
    ON (t1.column = t2.column)


No. The closest thing you can do with a natural join is:

SELECT
FROM T1, T2
WHERE t1.column = t2.column;


Yes. It's ANSI JOIN syntax. For example:

SELECT
   *
FROM T1
   INNER JOIN T2 ON T1.column = T2.column
;

For a multiple column join criteria, do the following:

SELECT
    *
FROM T1
   INNER JOIN T2 ON T2.column1 = T1.column1
      AND T2.column2 = T1.column2
   LEFT OUTER JOIN T3 ON T3.column1 = T2.column1 
;

Detailed, comprehensive information with examples is available in Chapter 2 of Teradata® RDBMS SQL Reference - Volume 6 Data Manipulation Statements.


If Teradata supports NATURAL JOINs, then you're set. In MySQL, NATURAL JOINs are INNER JOINs with a USING clause. Also, you can add a LEFT|RIGHT and OUTER clauses to the NATURAL clause to further specify how you want the JOIN made.

Check the documentation of Teradata, hopefully it should support it.

0

精彩评论

暂无评论...
验证码 换一张
取 消