【问题标题】:Join table using two identifiers not just one使用两个标识符连接表,而不仅仅是一个
【发布时间】:2012-10-16 20:50:27
【问题描述】:

我一直在试图找到一种方法来连接两个列标识符上的两个表。 即在“伪查询”中:

 join table1 to table2 where table1.x = table2.y and table1.a = table2.b

我可以在不明确使用 where 语句的情况下使用 join 语句来做到这一点吗?还是最好从 x=y 和 a=b 的 table1,table2 中选择?感谢您的建议!

【问题讨论】:

  • 什么类型的 SQL? MSSQL、MySQL、Oracle 等?请重新标记您的问题。
  • 它是CacheSQL,一种语法类似于Oracle的专有语言。

标签: sql intersystems-cache


【解决方案1】:

你可以像这样使用 from 子句:

from table1 inner join table2 on table1.x = table2.y and table1.a = table2.b

【讨论】:

    【解决方案2】:

    当然可以:

    select
     *
    from
        table1 a join table2 b on 
           (a.some_column = b.some_column and a.other_column = b.other_column)
    

    【讨论】:

      猜你喜欢
      • 2019-11-16
      • 1970-01-01
      • 1970-01-01
      • 2020-04-05
      • 2015-05-20
      • 1970-01-01
      • 2018-03-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多