Monday, March 19, 2012

joining rows

HI,
I've got a little problem. I have 2 rows in different tables ... is there
any way how to simply get these two 2 rows in table?
The rows are similar, only datas are different.
Thanks a lot.
S.You can join the 2 tables, filter on the specific record(s) you need, and
insert into another table using a single line. For example:
insert into MyTable
select
A.*,
B.*
from
A
left join
B on B.Date = A.Date
where
A.Date = xxx
"schnackie@.post.cz" <schnackiepostcz@.discussions.microsoft.com> wrote in
message news:A2DF5422-2B5D-44C3-B878-28656B30D988@.microsoft.com...
> HI,
> I've got a little problem. I have 2 rows in different tables ... is there
> any way how to simply get these two 2 rows in table?
> The rows are similar, only datas are different.
> Thanks a lot.
> S.|||schnackie@.post.cz wrote:
> HI,
> I've got a little problem. I have 2 rows in different tables ... is
> there any way how to simply get these two 2 rows in table?
> The rows are similar, only datas are different.
> Thanks a lot.
> S.
Please read:
www.aspfaq.com/5006
My guess is that you need a union query:
select <column list> from table1 where <criteria>
union all
select <column list> from table2 where <criteria>
You can use this in an insert statement:
Insert Into table3 (<column list> )
select <column list> from table1 where <criteria>
union all
select <column list> from table2 where <criteria>
Bob Barrows
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.|||Valid values of database compatibility level are 60, 65, or 70.
This means , I'm screwed :P
I'll have a look at this in BOL or the web thanks for the pointer into right
direction.
"schnackie@.post.cz" wrote:

> HI,
> I've got a little problem. I have 2 rows in different tables ... is there
> any way how to simply get these two 2 rows in table?
> The rows are similar, only datas are different.
> Thanks a lot.
> S.

No comments:

Post a Comment