Join two tables
Author Message
Join two tables

Hi,

Is it possible to join two tables so that the number of
the fields of the result will be the sum of that of the
two tables? Assume that there is no relationship between
the two tables and we can retrieve the same rows from two
tables.

For example:

Table1
AAA  1
BBB  2

Table2
CCC  3
DDD  4

Result will be:

AAA  1  CCC  3
BBB  2  DDD  4

This kind of join is neither Inner Join nor Outer Join. I

Any suggestion and ideas will be greatly appreciated.

Thanks

Andy

Mon, 13 Sep 2004 01:20:51 GMT
Join two tables
A "join" is based on a relationship between two tables, which you don't
have. If you specify a join without describing the relationship (Select *
From Table1, Table2) then you get a cross product, which is every row in one
table paired up with every row in the other table.

AAA 1 CCC 3
AAA 1 DDD 4
BBB 2 CCC 3
BBB 2 DDD 4

Not sure how to get your exact results without tweaking the tables or using
some code.

Quote:
> Hi,

> Is it possible to join two tables so that the number of
> the fields of the result will be the sum of that of the
> two tables? Assume that there is no relationship between
> the two tables and we can retrieve the same rows from two
> tables.

> For example:

> Table1
> AAA  1
> BBB  2

> Table2
> CCC  3
> DDD  4

> Result will be:

> AAA  1  CCC  3
> BBB  2  DDD  4

> This kind of join is neither Inner Join nor Outer Join. I

> Any suggestion and ideas will be greatly appreciated.

> Thanks

> Andy

Mon, 13 Sep 2004 02:34:28 GMT
Join two tables
Try the UNION Statement

(SELECT Field1, Field2 FROM Table1)
UNION
(SELECT Field1, Field2 FROM Table2)

This will only show completely unique rows so if you
expect duplicates, you'll need to add another field for
uniqueness purposes.

Hope this helps,
justin./

Quote:
>-----Original Message-----
>Hi,

>Is it possible to join two tables so that the number of
>the fields of the result will be the sum of that of the
>two tables? Assume that there is no relationship between
>the two tables and we can retrieve the same rows from two
>tables.

>For example:

>Table1
>AAA  1
>BBB  2

>Table2
>CCC  3
>DDD  4

>Result will be:

>AAA  1  CCC  3
>BBB  2  DDD  4

>This kind of join is neither Inner Join nor Outer Join. I

>Any suggestion and ideas will be greatly appreciated.

>Thanks

>Andy
>.

Mon, 13 Sep 2004 05:21:29 GMT
Join two tables
Identity(SQL Server)
to both tables.

After Join them you can drop this column.

Quote:
> Hi,

> Is it possible to join two tables so that the number of
> the fields of the result will be the sum of that of the
> two tables? Assume that there is no relationship between
> the two tables and we can retrieve the same rows from two
> tables.

> For example:

> Table1
> AAA  1
> BBB  2

> Table2
> CCC  3
> DDD  4

> Result will be:

> AAA  1  CCC  3
> BBB  2  DDD  4

> This kind of join is neither Inner Join nor Outer Join. I

> Any suggestion and ideas will be greatly appreciated.

> Thanks

> Andy

Mon, 13 Sep 2004 07:05:04 GMT

 Page 1 of 1 [ 4 post ]

Relevant Pages