Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 cross join inside grouo

Author  Topic 

jeff06
Posting Yak Master

166 Posts

Posted - 2007-08-20 : 14:16:26
table a
id group value
1 g1 2
2 g1 3
3 g2 4
4 g2 5
5 g2 10

table b
gourp name
g1 n1
g1 n2
g2 n4
g2 n5

I want ret table look like
1 g1 2 n1
1 g1 2 n2
2 g1 3 n1
2 g1 3 n2
3 g2 4 n4
3 g2 4 n5
4 g2 5 n4
4 g2 5 n5
5 g2 6 n4
5 g2 6 n4

How can I fulfill this task, thanks.
Jeff

jeff06
Posting Yak Master

166 Posts

Posted - 2007-08-20 : 14:21:21
sql server 2000
thanks
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-08-20 : 14:21:47
Similar to the suggestion you got here
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=88085



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-08-20 : 14:23:50
SELECT a.ID, a.Group, a.Value, b.Name
FROM TableA AS a
INNER JOIN TableB AS b ON b.Group = a.Group



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-08-20 : 14:25:47
And an
ORDER BY 1, 2, 3, 4
at the end of the query.



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

jeff06
Posting Yak Master

166 Posts

Posted - 2007-08-21 : 11:01:49
Thank you very much,
Peso!
Go to Top of Page
   

- Advertisement -