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
have not found a solution.

Any suggestion and ideas will be greatly appreciated.

Thanks

Andy  



Mon, 13 Sep 2004 01:27:29 GMT  
 Join two tables
SELECT tblTwo.*, tblOne.*
FROM tblTwo, tblOne;

Try that

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
>have not found a solution.

>Any suggestion and ideas will be greatly appreciated.

>Thanks

>Andy  

>.



Mon, 13 Sep 2004 02:19:16 GMT  
 Join two tables
Hi,

If there are no relationships betwenn tables, then there
is no sence to do that. Probably you need to merge tables
to get records from both of them in one recordset. Right?
In that case you can use UNION between SELECT statements
to do that

SELECT Field1, Field2 FROM TABLE1
UNION
SELECT Field1, Field2 FROM TABLE2

It will give you one recordset. But you should be aware
that number of selected fields in both (multiple) SELECT
statements has to be the same. Also type od filed should
be same or compatible

Val

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
>have not found a solution.

>Any suggestion and ideas will be greatly appreciated.

>Thanks

>Andy  

>.



Mon, 13 Sep 2004 02:22:30 GMT  
 Join two tables
Hi,

This is actually dangerous join, because it gives
resultset as a combination of each record from firts table
with each record from second one. In case if you have 1000
records in each table you will get resultset with
1,000,000 records in it

Val

Quote:
>-----Original Message-----
>SELECT tblTwo.*, tblOne.*
>FROM tblTwo, tblOne;

>Try that

>>-----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
>>have not found a solution.

>>Any suggestion and ideas will be greatly appreciated.

>>Thanks

>>Andy  

>>.

>.



Mon, 13 Sep 2004 02:39:01 GMT  
 Join two tables
Hi,

Thank you for your reply. But not work as the way I wanted.
Joining like this will create redundant combination of the
two tables.

Regards,
Andy

Quote:
>-----Original Message-----
>SELECT tblTwo.*, tblOne.*
>FROM tblTwo, tblOne;

>Try that

>>-----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
>>have not found a solution.

>>Any suggestion and ideas will be greatly appreciated.

>>Thanks

>>Andy  

>>.

>.



Mon, 13 Sep 2004 02:41:02 GMT  
 Join two tables
Hi Andy,

This is why it does not make any sence to join tables
without relationships

Val

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

>Thank you for your reply. But not work as the way I
wanted.
>Joining like this will create redundant combination of
the
>two tables.

>Regards,
>Andy

>>-----Original Message-----
>>SELECT tblTwo.*, tblOne.*
>>FROM tblTwo, tblOne;

>>Try that

>>>-----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
>>>have not found a solution.

>>>Any suggestion and ideas will be greatly appreciated.

>>>Thanks

>>>Andy  

>>>.

>>.

>.



Mon, 13 Sep 2004 02:50:07 GMT  
 Join two tables
Thank you for your reply.

The scenario is that I inherit the two tables from others.
Actually each of the two tables has many fields and they
had different items. In additon there are some code
related to those tables. If I changed tables, it would
probably lead to a crahdown. What I am trying is to find a
SQL statement to side by side add the records when
retrieving them or find a workaround. Is there a way in VB
code to achieve that?

Thanks
Andy

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

>If there are no relationships betwenn tables, then there
>is no sence to do that. Probably you need to merge tables
>to get records from both of them in one recordset. Right?
>In that case you can use UNION between SELECT statements
>to do that

>SELECT Field1, Field2 FROM TABLE1
>UNION
>SELECT Field1, Field2 FROM TABLE2

>It will give you one recordset. But you should be aware
>that number of selected fields in both (multiple) SELECT
>statements has to be the same. Also type od filed should
>be same or compatible

>Val

>>-----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
>>have not found a solution.

>>Any suggestion and ideas will be greatly appreciated.

>>Thanks

>>Andy  

>>.

>.



Mon, 13 Sep 2004 03:23:51 GMT  
 Join two tables
Hi, Val:

Thank you for your reply.
I hope to solve it because it exists as a real.
Right now I have a idea but haven't implemented yet.
Please give some comments after checking it.

I plan to do that as follows:

1 Set up a recordset with data structure as I desired.

rst1 = SELECT tbl1.fld1, tbl1.fld2, tbl2.fld1, tbl2.fld2
FROM tbl1, tbl2
WHERE 1<>0

2 Retieve recordsets from the two tables respectively.
rst2 = SELECT tbl1.fld1, tbl1.fld2 FROM tbl1
rst3 = SELECT tbl2.fld1, tbl2.fld2 FROM tbl2

3 Disconnect rst1 and populate it with rst2 and rst3

I am not sure about it.

Thanks
Andy

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

>This is why it does not make any sence to join tables
>without relationships

>Val

>>-----Original Message-----
>>Hi,

>>Thank you for your reply. But not work as the way I
>wanted.
>>Joining like this will create redundant combination of
>the
>>two tables.

>>Regards,
>>Andy

>>>-----Original Message-----
>>>SELECT tblTwo.*, tblOne.*
>>>FROM tblTwo, tblOne;

>>>Try that

>>>>-----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
>>>>have not found a solution.

>>>>Any suggestion and ideas will be greatly appreciated.

>>>>Thanks

>>>>Andy  

>>>>.

>>>.

>>.

>.



Mon, 13 Sep 2004 04:40:28 GMT  
 Join two tables
Hi,

Yes you can do that. But you still have problem that you
need to know which record from table2 put against which
record from table1. If you know it, then you can do that
just looping through recordsets

Val

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

>Thank you for your reply.
>I hope to solve it because it exists as a real.
>Right now I have a idea but haven't implemented yet.
>Please give some comments after checking it.

>I plan to do that as follows:

>1 Set up a recordset with data structure as I desired.

>rst1 = SELECT tbl1.fld1, tbl1.fld2, tbl2.fld1, tbl2.fld2
>FROM tbl1, tbl2
>WHERE 1<>0

>2 Retieve recordsets from the two tables respectively.
>rst2 = SELECT tbl1.fld1, tbl1.fld2 FROM tbl1
>rst3 = SELECT tbl2.fld1, tbl2.fld2 FROM tbl2

>3 Disconnect rst1 and populate it with rst2 and rst3

>I am not sure about it.

>Thanks
>Andy
>>-----Original Message-----
>>Hi Andy,

>>This is why it does not make any sence to join tables
>>without relationships

>>Val

>>>-----Original Message-----
>>>Hi,

>>>Thank you for your reply. But not work as the way I
>>wanted.
>>>Joining like this will create redundant combination of
>>the
>>>two tables.

>>>Regards,
>>>Andy

>>>>-----Original Message-----
>>>>SELECT tblTwo.*, tblOne.*
>>>>FROM tblTwo, tblOne;

>>>>Try that

>>>>>-----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
>>>>>have not found a solution.

>>>>>Any suggestion and ideas will be greatly appreciated.

>>>>>Thanks

>>>>>Andy  

>>>>>.

>>>>.

>>>.

>>.

>.



Mon, 13 Sep 2004 04:56:32 GMT  
 Join two tables
Hi Val:

Thank you very much.
Hopefully it will work :-)

Regards,
Andy

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

>Yes you can do that. But you still have problem that you
>need to know which record from table2 put against which
>record from table1. If you know it, then you can do that
>just looping through recordsets

>Val

>>-----Original Message-----
>>Hi, Val:

>>Thank you for your reply.
>>I hope to solve it because it exists as a real.
>>Right now I have a idea but haven't implemented yet.
>>Please give some comments after checking it.

>>I plan to do that as follows:

>>1 Set up a recordset with data structure as I desired.

>>rst1 = SELECT tbl1.fld1, tbl1.fld2, tbl2.fld1, tbl2.fld2
>>FROM tbl1, tbl2
>>WHERE 1<>0

>>2 Retieve recordsets from the two tables respectively.
>>rst2 = SELECT tbl1.fld1, tbl1.fld2 FROM tbl1
>>rst3 = SELECT tbl2.fld1, tbl2.fld2 FROM tbl2

>>3 Disconnect rst1 and populate it with rst2 and rst3

>>I am not sure about it.

>>Thanks
>>Andy
>>>-----Original Message-----
>>>Hi Andy,

>>>This is why it does not make any sence to join tables
>>>without relationships

>>>Val

>>>>-----Original Message-----
>>>>Hi,

>>>>Thank you for your reply. But not work as the way I
>>>wanted.
>>>>Joining like this will create redundant combination of
>>>the
>>>>two tables.

>>>>Regards,
>>>>Andy

>>>>>-----Original Message-----
>>>>>SELECT tblTwo.*, tblOne.*
>>>>>FROM tblTwo, tblOne;

>>>>>Try that

>>>>>>-----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
>>>>>>have not found a solution.

>>>>>>Any suggestion and ideas will be greatly appreciated.

>>>>>>Thanks

>>>>>>Andy  

>>>>>>.

>>>>>.

>>>>.

>>>.

>>.

>.



Mon, 13 Sep 2004 06:11:03 GMT  
 Join two tables
If tables are so different, why join them ?
You can use the LEFT JOIN to get data from both tables
but you'll need at least one field that contains the same data on each
table, that is, an index or an ID, etc.

--
Saludos, Jorge Jimenez, SICAD S.A., Costa Rica


Quote:
> Thank you for your reply.

> The scenario is that I inherit the two tables from others.
> Actually each of the two tables has many fields and they
> had different items. In additon there are some code
> related to those tables. If I changed tables, it would
> probably lead to a crahdown. What I am trying is to find a
> SQL statement to side by side add the records when
> retrieving them or find a workaround. Is there a way in VB
> code to achieve that?

> Thanks
> Andy

> >-----Original Message-----
> >Hi,

> >If there are no relationships betwenn tables, then there
> >is no sence to do that. Probably you need to merge tables
> >to get records from both of them in one recordset. Right?
> >In that case you can use UNION between SELECT statements
> >to do that

> >SELECT Field1, Field2 FROM TABLE1
> >UNION
> >SELECT Field1, Field2 FROM TABLE2

> >It will give you one recordset. But you should be aware
> >that number of selected fields in both (multiple) SELECT
> >statements has to be the same. Also type od filed should
> >be same or compatible

> >Val

> >>-----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
> >>have not found a solution.

> >>Any suggestion and ideas will be greatly appreciated.

> >>Thanks

> >>Andy

> >>.

> >.



Mon, 13 Sep 2004 14:02:08 GMT  
 
 [ 11 post ] 

 Relevant Pages 

1. Joining two tables from two databases

2. Here's a sticky wicket - joining two tables on two diffrent servers with ADO

3. Joining two tables from different databases

4. How to Join two tables thrice?

5. Join two tables

6. Joining two tables on different length fields

7. Join two tables from seperate databases

8. joining two tables from different dbs

9. Joining two tables from different dbs

10. VB? how to inner join two tables in two MS Access database

11. Urg:It is possible to join two tables from two different databases ?

12. Table join between two tables in different databases

 

 
Powered by phpBB® Forum Software