Hello..I need help
Surporse I have a table TBRelation with 4 columns A1,B1,A2,B2 all are int.
this table has two relation with a table called TB with 2 colums A, B they
are composite primary key.
How can I to create a query that insert in tbRelation with the result of 2
queries?
wrong query today:...
insert into tbrelation
A1, B1, A2, B2)
select a,b from tb where culture = 'es-au'
select a,b from tb where culture = 'pt-br'
Result that I should want:
A1 - B1 - A2 - B2
1 1 2 2
someone can help me?Try,
insert into tbrelation (A1, B1, A2, B2)
select a.a, a.b, b.a, b.b
from
(
select top 1 a, b from tb where culture = 'es-au'
) as a
cross join
(
select top 1 a, b from tb where culture = 'pt-br'
) as b
go
AMB
"EdwinSlyfingster" wrote:
> Hello..I need help
> Surporse I have a table TBRelation with 4 columns A1,B1,A2,B2 all are int.
> this table has two relation with a table called TB with 2 colums A, B they
> are composite primary key.
> How can I to create a query that insert in tbRelation with the result of 2
> queries?
> wrong query today:...
> insert into tbrelation
> A1, B1, A2, B2)
> select a,b from tb where culture = 'es-au'
> select a,b from tb where culture = 'pt-br'
>
> Result that I should want:
> A1 - B1 - A2 - B2
> 1 1 2 2
> someone can help me?
>|||On Wed, 16 Nov 2005 04:30:02 -0800, EdwinSlyfingster wrote:
>Hello..I need help
>Surporse I have a table TBRelation with 4 columns A1,B1,A2,B2 all are int.
>this table has two relation with a table called TB with 2 colums A, B they
>are composite primary key.
>How can I to create a query that insert in tbRelation with the result of 2
>queries?
>wrong query today:...
>insert into tbrelation
>A1, B1, A2, B2)
>select a,b from tb where culture = 'es-au'
>select a,b from tb where culture = 'pt-br'
>
>Result that I should want:
>A1 - B1 - A2 - B2
>1 1 2 2
>someone can help me?
Hi EdwinSlyfingster,
INSERT INTO Relation (A1, B1, A2, B2)
SELECT t1.A, t1.B, t2.A, t2.B
FROM tb AS t1
CROSS JOIN tb AS t2
WHERE t1.culture = 'es-au'
AND t2.culture = 'pt-br'
(untested - see www.aspfaq.com/5006 if you prefer a tested solution)
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment