joinx()

阅读(698) 标签: 连接, 游标,

描述:

连接游标对应的序表

语法:

joinx(csi:Fi,xj,..;…)

备注:

针对有序游标csi的结果集做join@m,返回新游标,xj参数全省略则使用主键进行连接. xj参数没主键则使用xj的值进行连接。支持多路游标,多路游标时必须路数相同。csi也可以是序表。

假定xj 有序,将多个游标csi按照关联字段/关联表达式xjx1相等的关系进行连接,产生以Fi,…为字段的游标。Fi为引用字段,引用原游标序列csi中的记录。注意:xj仅支持升序。

不管是多少个游标之间关联,都是和cs1中的x1进行相等判断,因此是一对多的关系

 

选项:

@f

全连接,找不到匹配值时,则与null对应

@1

左连接(注意:这里是数字1,不是字母l

@p

按位置连接,忽略xj参数

@u

只有cs1是游标,其它都是内存序表,此时不要求有序

参数:

Fi

结果序表的字段名

csi

用于连接的游标或序表

xj

连接字段/表达式

返回值:

游标

示例:

 

A

 

1

=demo.cursor("select * from EMPLOYEE order by  EID" )

 

2

=demo.cursor("select * from PERFORMANCE order by  EMPLOYEEID")

 

3

=joinx(A1:EmployeeID1,EID;A2:EmployeeID2,EMPLOYEEID)

常规连接,不匹配的项丢弃,每个字段值指向原游标的一条记录

4

=A3.fetch()

 

5

=demo.cursor("select * from EMPLOYEE order by  EID" )

 

6

=demo.cursor("select * from PERFORMANCE order by  EMPLOYEEID")

 

7

=joinx@f(A5:EmployeeID1,EID;A6: EmployeeID2,EMPLOYEEID)

全连接,无匹配项的用null

8

=A7.fetch()

9

=demo.cursor("select * from EMPLOYEE order by  EID" )

 

10

=demo.cursor("select * from PERFORMANCE order by  EMPLOYEEID")

 

11

=joinx@1(A9:EmployeeID2,EID-5;A10:EmployeeID1,EMPLOYEEID)

左连接,以第一个游标为基准,无匹配项的用null

12

=A11.fetch()

 

13

=demo.cursor("select * from EMPLOYEE order by  EID" )

 

14

=demo.cursor("select * from PERFORMANCE where EMPLOYEEID>3 order by  EMPLOYEEID ")

 

15

=joinx@p(A13:EmployeeID2;A14:EmployeeID1).fetch()

按位置连接

16

=demo.query("select top 3 EID,NAME from EMPLOYEE")

 

17

=A16.modify(2,2,null)

 

18

=A16.cursor()

 

19

=demo.cursor("select top 20 * from EMPLOYEE")

 

20

=joinx(A18:Employee1,EID,NAME;A19: Employee2,EID,NAME)

根据EIDNAME连接

21

=A20.fetch()

22

=demo.query("select top 3 EID,NAME from EMPLOYEE").keys(EID)

 

23

=A22.cursor()

 

24

=demo.query("select top 20 * from EMPLOYEE").keys(EID)

 

25

=A24.cursor()

 

26

=joinx(A23:Employee1;A25: Employee2)

使用主键进行连接

27

=A26.fetch()

28

=demo.cursor("select * from EMPLOYEE" )

 

29

=demo.query("select * from PERFORMANCE")

 

30

=joinx@u(A28:EmployeeID1,EID;A29:EmployeeID2,EMPLOYEEID)

使用@u选项,只有A28是游标,其它是内存序表,此时不要求有序

 

31

=A30.fetch()

相关概念:

join()