简体   繁体   English

MS-Access上无条件加入(无条件加入)

[英]Join with no Condition on MS-Access (Unconditional Join)

Suppose I have two tables: 假设我有两个表:

ColX      ColY
--------  --------
Jim       26
Jake      5
Anastase  64

ColA      ColB
--------  --------
55523265  true
29874902  false
90387546  true

I would like to Join them into one table as follows: 我想将它们加入到一个表中,如下所示:

ColX      ColB
--------  --------
Jim       true
Jake      false
Anastase  true

I tried creating a query as follows: 我尝试创建查询,如下所示:

Select T1.ColX, S2.Mark FROM S1
INNER JOIN S2 ON 1=1

But MS-Access doesn't like that. 但是MS-Access不喜欢这样。 It says that Join Statement is not Supported. 它说不支持Join语句。 Any pointers in the right direction are appreciated. 任何朝着正确方向的指针都值得赞赏。

Edit: It is probably worth noting two things: 编辑:可能值得注意两件事:

  1. This is a deliberate attempt at an Inference attack for a security course. 这是针对安全过程的推理攻击的蓄意尝试。
  2. MS-Access does not have a rownumber() function. MS-Access没有rownumber()函数。

You have to have something that relates one table to another. 您必须具有将一个表与另一个表相关联的东西 You can't count on row position. 您不能指望行位置。 You can add a column with a sequential number and join on that, but otherwise what you're asking makes no sense. 您可以添加一个具有序号的列并将其连接起来,但是否则,您的要求就没有意义了。

This is dangerous territory and is not a good general solution. 这是危险的领域,不是一个好的通用解决方案。 But if this is a one off and you know the alignment between the two tables happens to be is perfect (like, if you literally pasted columns together in Excel that you could visually inspect for alignment), you can run this on each: 但是,如果这是一次性的,并且您知道两个表之间的对齐恰好是完美的(例如,如果您在Excel中逐字地将列粘贴到一起,可以直观地检查对齐情况),则可以在每个表上运行此命令:

ALTER TABLE mytable1 ADD COLUMN row_id COUNTER

ALTER TABLE mytable2 ADD COLUMN row_id COUNTER

and then join on row_id . 然后加入row_id

But your join will only work if the order / alignment happens to be perfect. 但是,只有顺序/对齐方式恰好完美时,您的加入才会起作用。 Beware. 谨防。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM