X++中的Join

  • 2021-11-01
  • Admin
  1. InnerJoin(内连接):
    –组合数据源 – 从主表中根据条件选择与连接表中的记录相匹配的记录,反之亦然。
    例:
    select AccountNum from custTable
    join TaxGroupId from custGroup
    where custGroup.CustGroup == custTable.CustGroup;

  2. Outer Join(外连接),
    –组合数据源 – 从主表中选择记录。无论在连接表中是否有匹配的记录,都会检索这些记录。
    select AccountNum from custTable
    outer join AccountID from custBankAccount
    where custBankAccount.CustAccount == custTable.AccountNum;

  3. Exists Join:

    • 数据源从主表中为连接表中的每个匹配记录检索一条记录。
      InnerJoin 和 ExistJoin 的区别如下:
      · 当连接类型为 ExistJoin 时,搜索在找到第一个匹配项后结束。
      · 当连接类型为InnerJoin 时,搜索所有匹配的记录。
      如果在执行 join 子句后结果集中有任何记录,则返回 true。否则返回 false。
      例:
      select AccountNum from custBankAccount
      exists join custTable
      where custBankAccount.CustAccount == custTable.AccountNum;
  4. NotExists Join: –组合数据源-从主表中选择在连接表中没有匹配项的记录。
    如果在执行 join 子句后结果集中有任何记录,则返回 false。否则返回真。
    例:
    select AccountNum from custBankAccount
    notexists join custTable
    where custBankAccount.CustAccount == custTable.AccountNum;
    参考博客

原文:https://blog.csdn.net/m0_46115516/article/details/121076802

联系站长

QQ:769220720