Subject | RE: [firebird-support] How to join unrelated tables? |
---|---|
Author | Werner Cloete |
Post date | 2004-06-14T13:15:34Z |
I did something like this some time back...so I'm typing from (shoddy)
memory...
Try the following - or, at least, this should get you on your way :
select <field 1>, <field 2>, <field 3>,
cast(null as varchar(<field 4's size>)) as <field 4's name>,
cast(null as varchar(<field 5's size>)) as <field 5's name>,
cast(null as varchar(<field 6's size>)) as <field 6's name>
from <table 1>
union
select cast(null as integer) as <field 1's name>,
cast(null as integer) as <field 2's name>,
cast(null as integer) as <field 3's name>,
<field 4>, <field 5>, <field 6>
from <table 2>
Now, if I remembered correctly (holding thumbs), this should work...
Best of luck..!
Werner
-----Original Message-----
From: kimon_the_athenian2 [mailto:kimon_the_athenian2@...]
Sent: 14 June 2004 15:08
To: firebird-support@yahoogroups.com
Subject: [firebird-support] How to join unrelated tables?
Hi!
If table1 data is:
1,2,3
4,5,6
and table2 data is
a,b,c
d,e,f
then, is it possible to construct a join to get:
1,2,3,-,-,-
4,5,6,-,-,-
-,-,-,a,b,c
-,-,-,d,e,f
where - means NULL?
I'm sorry if this question isn't Firebird specific but I didn't know
a better place to ask.
Aivar
This e-mail message is confidential and intended solely for the person to whom or the entity to which it is addressed. All the contents and any attachments remain the property of VR Services (Pty) Ltd unless so stated by contract.
If you are not the intended recipient, you are prohibited from reading, copying, using or disclosing this message to others.
If you received this message in error, please notify the sender immediately by replying to this e-mail or by telephoning +27 21 430 9300 and thereafter delete the message. VR Services (Pty) Ltd does not accept liability for any personal views expressed in this message.
memory...
Try the following - or, at least, this should get you on your way :
select <field 1>, <field 2>, <field 3>,
cast(null as varchar(<field 4's size>)) as <field 4's name>,
cast(null as varchar(<field 5's size>)) as <field 5's name>,
cast(null as varchar(<field 6's size>)) as <field 6's name>
from <table 1>
union
select cast(null as integer) as <field 1's name>,
cast(null as integer) as <field 2's name>,
cast(null as integer) as <field 3's name>,
<field 4>, <field 5>, <field 6>
from <table 2>
Now, if I remembered correctly (holding thumbs), this should work...
Best of luck..!
Werner
-----Original Message-----
From: kimon_the_athenian2 [mailto:kimon_the_athenian2@...]
Sent: 14 June 2004 15:08
To: firebird-support@yahoogroups.com
Subject: [firebird-support] How to join unrelated tables?
Hi!
If table1 data is:
1,2,3
4,5,6
and table2 data is
a,b,c
d,e,f
then, is it possible to construct a join to get:
1,2,3,-,-,-
4,5,6,-,-,-
-,-,-,a,b,c
-,-,-,d,e,f
where - means NULL?
I'm sorry if this question isn't Firebird specific but I didn't know
a better place to ask.
Aivar
This e-mail message is confidential and intended solely for the person to whom or the entity to which it is addressed. All the contents and any attachments remain the property of VR Services (Pty) Ltd unless so stated by contract.
If you are not the intended recipient, you are prohibited from reading, copying, using or disclosing this message to others.
If you received this message in error, please notify the sender immediately by replying to this e-mail or by telephoning +27 21 430 9300 and thereafter delete the message. VR Services (Pty) Ltd does not accept liability for any personal views expressed in this message.