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 2000 Forums
 Transact-SQL (2000)
 join query doubt

Author  Topic 

desikankannan
Posting Yak Master

152 Posts

Posted - 2008-02-18 : 08:12:35
Hi,
iam working in a asp.net project, i have two table tblcouptypm,tblpoltym

in firt table the structure is
FIRST TABLE NAME - tblcouptypm
fldccode,fldmeaning,flddesc,fldactive
G--------GARGAGE-----GARGEDES-----y
P--------DFD---------RIT----------N
S--------SUPPLIER----SUPPLIERDES--N
U--------UNIT--------UNITDESC-----Y

SECOND TABLE NAME - tblpoltym
fildtcode,fldpolname,fldccode,fldactivate
TY0002----THEGRAY-------P----------N
TY0002----THEGRAY-------S----------N
TY0002----THEGRAY-------U----------N

I NEED THE BELOW OUTPUT URGENTLY PLEASE GUIDE ME PLEASE VERY URGENT I WANTS TO GET OUTPUT BELOW I MEANTIONED

FILDTCODE,FLDPOLNAME,FLDMEANING,FLDCCODE,FLDACTIVATE
TY0002----THEGRAY-----DFD-------P---------N
TY0002----THEGRAY-----SUPPLIER--S---------N
TY0002----THEGRAY-----UNIT------U---------N
TY0002----THEGRAY-----GARGAGE---G---------N



Regards
kannan.d


Desikankannan

jhocutt
Constraint Violating Yak Guru

385 Posts

Posted - 2008-02-18 : 08:20:43
select a.FILDTCODE a.FLDPOLNAME b.FLDMEANING a.FLDCCODE a.FLDACTIVATE
from tblcouptypm a left join tblpoltym b on a.fldccode = b.fldccode


"God does not play dice" -- Albert Einstein
"Not only does God play dice, but he sometimes throws them where they cannot be seen."
-- Stephen Hawking
Go to Top of Page

elancaster
A very urgent SQL Yakette

1208 Posts

Posted - 2008-02-18 : 08:50:31
quote:

Hi,
iam working in a asp.net project, i have two table tblcouptypm,tblpoltym

in firt table the structure is
FIRST TABLE NAME - tblcouptypm
fldccode,fldmeaning,flddesc,fldactive
G--------GARGAGE-----GARGEDES-----y
P--------DFD---------RIT----------N
S--------SUPPLIER----SUPPLIERDES--N
U--------UNIT--------UNITDESC-----Y

SECOND TABLE NAME - tblpoltym
fildtcode,fldpolname,fldccode,fldactivate
TY0002----THEGRAY-------P----------N
TY0002----THEGRAY-------S----------N
TY0002----THEGRAY-------U----------N

I NEED THE BELOW OUTPUT URGENTLY PLEASE GUIDE ME PLEASE VERY URGENT I WANTS TO GET OUTPUT BELOW I MEANTIONED

FILDTCODE,FLDPOLNAME,FLDMEANING,FLDCCODE,FLDACTIVATE
TY0002----THEGRAY-----DFD-------P---------N
TY0002----THEGRAY-----SUPPLIER--S---------N
TY0002----THEGRAY-----UNIT------U---------N
TY0002----THEGRAY-----GARGAGE---G---------N




i don't understand your sample data. this last row (in red) it doesn't join to the other table and you've just decided to give it the same values? i.e. thegray, TY0002, N ...what's your logic here?

Em
Go to Top of Page

desikankannan
Posting Yak Master

152 Posts

Posted - 2008-02-18 : 08:55:48
Hi,
thanks for your reply
select b.FILDTCODE, b.FLDPOLNAME, a.FLDMEANING, a.FLDCCODE ,b.FLDACTIVATE
from tblcouptypm a left join tblpoltypm b on a.fldccode = b.fldccode
what i want is that instead of null i wants below value
null should be replace as TY0002, THEGRAY,N


NULL----NULL----Gargage----G----NULL
TY0002--THEGRAY--DFD-------P----N
TY0002--THEGRAY--Suppliers-S----N
TY0002--THEGRAY--UNIT------U----N









quote:
Originally posted by jhocutt

select a.FILDTCODE a.FLDPOLNAME b.FLDMEANING a.FLDCCODE a.FLDACTIVATE
from tblcouptypm a left join tblpoltym b on a.fldccode = b.fldccode


"God does not play dice" -- Albert Einstein
"Not only does God play dice, but he sometimes throws them where they cannot be seen."
-- Stephen Hawking



Desikankannan
Go to Top of Page

jhocutt
Constraint Violating Yak Guru

385 Posts

Posted - 2008-02-18 : 09:00:32
Then add

TY0002----THEGRAY-------G----------N
to tblpoltym

"God does not play dice" -- Albert Einstein
"Not only does God play dice, but he sometimes throws them where they cannot be seen."
-- Stephen Hawking
Go to Top of Page

desikankannan
Posting Yak Master

152 Posts

Posted - 2008-02-18 : 09:06:15


Hi,
need like this

NULL----NULL----Gargage----G----NULL--THIS SHOULD BE REPLACED
AS TY0002----THEGRADY----Gargage----G----N




quote:
Originally posted by jhocutt

Then add

TY0002----THEGRAY-------G----------N
to tblpoltym

"God does not play dice" -- Albert Einstein
"Not only does God play dice, but he sometimes throws them where they cannot be seen."
-- Stephen Hawking



Desikankannan
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-02-18 : 09:36:08
select coalesce(b.FILDTCODE,'AS TY0002') as FILDTCODE, coalesce(b.FLDPOLNAME,THEGRADY) as FLDPOLNAME,a.FLDMEANING, a.FLDCCODE ,coalesce(b.FLDACTIVATE,'N') as FLDACTIVATE
from tblcouptypm a left join tblpoltypm b on a.fldccode = b.fldccode


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -