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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Need help on query

Author  Topic 

Delinda
Constraint Violating Yak Guru

315 Posts

Posted - 2010-02-17 : 22:21:03
I've table and row as follow,
trip
tid | RID
------------------------------------------
_d091100007569 _r00000006
_d091100007571 _r00000006
_d091100007716 _r00000008
/*tid is a unique*/

cout
RID | Cout | Posi
--------------------------------
_r00000006 KL 1
_r00000006 JB 2
_r00000008 SG 1
_r00000008 BI 2
_r00000008 KL 3
_r00000010 JB 1

How to query, so my resultset as follow,
tid | RID | Cout | Posi
-----------------------------------------------------------
_d091100007569 _r00000006 KL 1
_d091100007569 _r00000006 JB 2
_d091100007571 _r00000006 KL 1
_d091100007571 _r00000006 JB 2
_d091100007716 _r00000008 SG 1
_d091100007716 _r00000008 BI 2
_d091100007716 _r00000008 KL 3

Sachin.Nand

2937 Posts

Posted - 2010-02-17 : 22:28:52
select t1.tid,t1.rid,c1.cout,c1.posi from trip t1
left join cout c1 on c1.rid=t1.rid

PBUH
Go to Top of Page

Delinda
Constraint Violating Yak Guru

315 Posts

Posted - 2010-02-17 : 23:47:40
tq sir
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-02-18 : 00:57:03
quote:
Originally posted by Idera

select t1.tid,t1.rid,c1.cout,c1.posi from trip t1
left join cout c1 on c1.rid=t1.rid

PBUH


why left join? isnt inner join enough as per sample data?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -