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)
 outer join question??

Author  Topic 

csphard
Posting Yak Master

113 Posts

Posted - 2004-11-29 : 16:47:31
I am trying to get all the sect items in the profile table,
and any that are in the sub sites table that are not in the profile
table. The following represents the sql i created. The problem is that it only lists the items in the profile table and does not include
the ones that are only in the sub site table.


select distinct sect from profile p
left join sub_sites s on
p.sect = s.sect
order by p.sect

JCamburn
Starting Member

31 Posts

Posted - 2004-11-29 : 17:02:25
This will give you all the items in the profile table

SELECT sect FROM profile


And this will give you all the items from sub_sites

SELECT sect FROM sub_sites


If you want them all together, then UNION them.

SELECT sect FROM profile
UNION
SELECT sect FROM sub_sites


Which will eliminate the duplicates for you.
Go to Top of Page

rockmoose
SQL Natt Alfen

3279 Posts

Posted - 2004-11-29 : 17:03:27

select sect from profile
union
select sect from sub_sites

rockmoose
Go to Top of Page
   

- Advertisement -