Click here to Skip to main content
15,907,913 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SQL
ALTER PROC [dbo].[GET_PDFEXPORT](@ENT_NUM as varchar(10))
as
select a.Enterprise_number,a.Name,b.Report_Type as Report,b.Red_Flag as FileType, c.Link as SEC_LINK from T_CompanyFinancial a
join T_Tracking b on a.Enterprise_number=b.Enterprise_number
join T_Allocation c on a.Enterprise_number=c.Enterprise_Number
where a.Enterprise_number=@ENT_NUM


hi from above query i have following doubt

I need link from t_allocation table so there is need to use join here
but same time all the Enterprise_number from T_CompanyFinancial not presented in table T_allocation
if Enterprise_number is not present in T_allocation means sec_link can be blank

HOw can do this

Help me thanks
Posted

hi,
you can use left join query. it may help you,
SQL
SELECT a.Enterprise_number,a.Name,b.Report_Type as Report,b.Red_Flag as FileType, c.Link as SEC_LINK 
FROM T_CompanyFinancial a
INNER JOIN T_Tracking b on a.Enterprise_number=b.Enterprise_number
LEFT OUTER JOIN T_Allocation c on a.Enterprise_number=c.Enterprise_Number
WHERE a.Enterprise_number=@ENT_NUM


regards,
Prakash.T
 
Share this answer
 
v2
Comments
kimberly wind 1-Mar-13 2:21am    
Hi i tried but now its taking Enterprise number from t_allocation table which is not present in
T_CompanyFinancial
kimberly wind 1-Mar-13 2:27am    
thanks it works good :)
kimberly wind 1-Mar-13 2:28am    
my 5
Hi,

try with OUTER JOIN for T_Allocation table.
SQL
select a.Enterprise_number,a.Name,b.Report_Type as Report,b.Red_Flag as FileType, c.Link as SEC_LINK from T_CompanyFinancial a
join T_Tracking b on a.Enterprise_number=b.Enterprise_number
LEFT OUTER join T_Allocation c on a.Enterprise_number=c.Enterprise_Number
where a.Enterprise_number=@ENT_NUM


hope it helps
 
Share this answer
 
Comments
kimberly wind 1-Mar-13 2:21am    
Hi i tried but now its taking Enterprise number from t_allocation table which is not present in
T_CompanyFinancial
kimberly wind 1-Mar-13 2:28am    
its correct and thanks it works 5n my 5
Karthik Harve 1-Mar-13 2:32am    
Welcome. and Happy coding :-)
 
Share this answer
 
v3
Comments
kimberly wind 1-Mar-13 2:35am    
Hi thanks for the link

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900