简体   繁体   中英

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. It says that Join Statement is not Supported. 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.

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:

ALTER TABLE mytable1 ADD COLUMN row_id COUNTER

ALTER TABLE mytable2 ADD COLUMN row_id COUNTER

and then join on row_id .

But your join will only work if the order / alignment happens to be perfect. Beware.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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