June 7, 2013 at 3:58 am
Hello,
I am also news in this field...
June 7, 2013 at 10:48 am
However the columns are named, you can use the query from the first structure to discern the query for your actual table structure. Also, don't discount Jeff's post about looking it up. Having the answer is one thing, but understanding it is another. You shouldn't just run code you're given unless you understand it and test it yourself.
Joins are fundamental to SQL and understanding them is pretty critical if you want to continue to work in it. What Jeff was doing it showing you where to look to get the answer. Knowing how to read MSDN is an important part of working in SQL Server.
June 7, 2013 at 12:43 pm
Ed Wagner (6/7/2013)
However the columns are named, you can use the query from the first structure to discern the query for your actual table structure. Also, don't discount Jeff's post about looking it up. Having the answer is one thing, but understanding it is another. You shouldn't just run code you're given unless you understand it and test it yourself.Joins are fundamental to SQL and understanding them is pretty critical if you want to continue to work in it. What Jeff was doing it showing you where to look to get the answer. Knowing how to read MSDN is an important part of working in SQL Server.
Spot on, Ed. Thanks for the support.
--Jeff Moden
Change is inevitable... Change for the better is not.
June 17, 2013 at 6:05 am
Try this code
declare @table1 TABLE
(
col1 int,
col2 char(2),
col3 char(2)
)
insert into @table1 values(1,'_A','11')
insert into @table1 values(2,'_B','12')
insert into @table1 values(3,'_C','12')
insert into @table1 values(4,'_A','11')
declare @table2 TABLE
(
id char(2),
val char(2)
)
insert into @table2 values('_A','A')
insert into @table2 values('_B','B')
insert into @table2 values('_C','C')
insert into @table2 values('11','AA')
insert into @table2 values('12','BB')
insert into @table2 values('13','CC')
select t1.col1,t1.col2,t2.val from @table1 t1 INNER JOIN @table2 t2
ON t1.col3=t2.id
OUTPUT:
col1 col2 val
----------- ---- ----
1 _A AA
2 _B BB
3 _C BB
4 _A AA
June 17, 2013 at 1:35 pm
Thank you
Viewing 5 posts - 16 through 19 (of 19 total)
You must be logged in to reply to this topic. Login to reply