Posts Topics Forums Images
Search videos from message boards Videos Search messages from microblogs Microblogs Search messages from imdb.com Imdb Search messages from yuku.com Yuku Search messages from lefora.com (free forums) Lefora
My account: Login | Sign Up
Loading... 

Thread: horizontal union operation

Started 1 month, 3 weeks ago by loyal ginger
I have two irrelavent Microsoft Access tables. They have the same number of records but no other relations. Is there a way to create a new table using SQL with fields from the two source tables put together? For example: Table1 : Name Address --------------------- John 302 ABC Street Smith 412 DEF Street Table2 : Phone email ---------------------- ...
Site: CodeProject: Discussion Boards. Free source code and programming help  CodeProject: Discussion Boards. Free source code and programming help - site profile
Forum: SQL / ADO / ADO.NET  SQL / ADO / ADO.NET - forum profile
Total authors: 6 authors
Total thread posts: 7 posts
Thread activity: no new posts during last week
Domain info for: codeproject.com

Other posts in this thread:

Garth J Lancaster replied 1 month, 3 weeks ago
I'm wondering what you'd do if you had to 'resort to writing a custom program?' - since as you say, they are (I'll use the terms) disjoint/un-related instead of your 'irrelavent' since you dont have anything in common between the tables, and as you say, you cant join by record numbers the only way I can see of doing this (which assumes you can see record numbers) is to manually create a 'link' ...

Luc Pattyn replied 1 month, 3 weeks ago
Hi, if everything else fails, you could add a field to both tables ("ID") and fill it with sequential numbers. Then join both tables on the new field.

Niladri_Biswas replied 1 month, 3 weeks ago
Try this declare @tbl1 table(name varchar(20), address varchar(50)) insert into @tbl1 select 'John','302 ABC Street' union all select 'Smith','412 DEF Street' declare @tbl2 table(phone varchar(20), email varchar(50)) insert into @tbl2 select '123-4567','m1@hotmail.com' union all select '234-5678','s1@gmail.com' ;with cte1 as ( select t1.*, ROW_NUMBER() over ( order by name) as ...

dxlee replied 1 month, 3 weeks ago
First of all, thanks for all who replied. I was given those Access tables and was asked to do that "horizontal join". I did not design the database, so I have no control over the design of the tables. For example, there is no primary key in those tables. Had I designed them, I would probably put a rowid field there as the primary key. The person who asked me to do this needed the result table ...

Shameel replied 1 month, 2 weeks ago
You cannot do this in Access :(

Shameel replied 1 month, 2 weeks ago
Add a new AutoNumber column to both these tables and use it to join the tables.

 

Top contributing authors

Name
Posts
Shameel
2
user's latest post:
horizontal union operation
Published (2009-11-09 10:05:00)
Add a new AutoNumber column to both these tables and use it to join the tables.
loyal ginger
1
user's latest post:
horizontal union operation
Published (2009-11-05 16:03:00)
I have two irrelavent Microsoft Access tables. They have the same number of records but no other relations. Is there a way to create a new table using SQL with fields from the two source tables put together? For example: Table1 : Name Address --------------------- John 302 ABC Street Smith 412 DEF Street Table2 : Phone email ---------------------- 123 - 4567 m1@hotmail.com 234 - 5678 s1@gmail.com Can I use a simple SQL command to create:...
Garth J Lancaster
1
user's latest post:
horizontal union operation
Published (2009-11-05 16:45:00)
I'm wondering what you'd do if you had to 'resort to writing a custom program?' - since as you say, they are (I'll use the terms) disjoint/un-related instead of your 'irrelavent' since you dont have anything in common between the tables, and as you say, you cant join by record numbers the only way I can see of doing this (which assumes you can see record numbers) is to manually create a 'link'...
Luc Pattyn
1
user's latest post:
horizontal union operation
Published (2009-11-05 18:59:00)
Hi, if everything else fails, you could add a field to both tables ("ID") and fill it with sequential numbers. Then join both tables on the new field.
Niladri_Biswas
1
user's latest post:
horizontal union operation
Published (2009-11-05 23:07:00)
Try this declare @tbl1 table(name varchar(20), address varchar(50)) insert into @tbl1 select 'John','302 ABC Street' union all select 'Smith','412 DEF Street' declare @tbl2 table(phone varchar(20), email varchar(50)) insert into @tbl2 select '123-4567','m1@hotmail.com' union all select '234-5678','s1@gmail.com' ;with cte1 as ( select t1.*, ROW_NUMBER() over (...
dxlee
1
user's latest post:
horizontal union operation
Published (2009-11-06 11:44:00)
First of all, thanks for all who replied. I was given those Access tables and was asked to do that "horizontal join". I did not design the database, so I have no control over the design of the tables. For example, there is no primary key in those tables. Had I designed them, I would probably put a rowid field there as the primary key. The person who asked me to do this needed the result table "so that he can load the table in...

Related threads on "CodeProject: Discussion Boards. Free source code and programming help":

Related threads on other sites:

Thread profile page for "horizontal union operation" on http://www.codeproject.com. This report page is a snippet summary view from a single thread "horizontal union operation", located on the Message Board at http://www.codeproject.com. This thread profile page shows the thread statistics for: Total Authors, Total Thread Posts, and Thread Activity