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
 left join help

Author  Topic 

gfaryd
Starting Member

27 Posts

Posted - 2012-06-20 : 06:01:17
dear all

select a.c_no, b.Name, b.father_name, a.Status,
a.Region
from main_tab a left join detail b
on a.c_no = b.c_no where
a.c_no = '25'

c_no 25 does not exist in detail table but exist in main
table i want that columns from detail table return null
and data from main_tab against c_no 25 should be populated.
i m using above query but no avail
any help

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2012-06-20 : 06:29:10
Think that shoould work. Are you sure that it is in main and that you didn't run wher eb.c_no = '25'?
Try
select *
from main_tab a
left join detail b
on a.c_no = b.c_no
where a.c_no = '25'

then
select *
from main_tab a
--left join detail b
--on a.c_no = b.c_no
where a.c_no = '25'



==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

vinu.vijayan
Posting Yak Master

227 Posts

Posted - 2012-06-20 : 06:29:42
Can't say anything by just looking at the query.
You will have to post DDL of the tables and some sample data so that we can see what you are looking at.

N 28° 33' 11.93148"
E 77° 14' 33.66384"
Go to Top of Page
   

- Advertisement -