Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Query Help (Two Tables) 1

Status
Not open for further replies.

jrball

Technical User
Jul 19, 2005
28
US
I have two tables that I need to get data from

Objects:

PubID ModuleID Name CreatedDate
123456 620 Briefs 2/21/2007 2/21/2007
123455 620 Briefs 2/20/2007 2/20/2007
123454 620 Briefs 2/19/2007 2/19/2007


Views:
PubID ViewBy TimesViewed
123456 jdoe 1
123456 bdoe 1
123455 jdoe 2

I need to get this somehow: (Everything in the objects table not viewed in the views table by bdoe)

PubID ModuleID Name CreatedDate
123455 620 Briefs 2/20/2007 2/20/2007
123454 620 Briefs 2/19/2007 2/19/2007

How do I form the SQL select statement?
 
try this...

Code:
Select *
From   objects
       Left Join views
         On objects.pubid = views.pubid
Where  views.ViewBy = 'bdoe'
       and views.pubid is null



-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Code:
select Objects.PubID          
     , Objects.ModuleID        
     , Objects.Name              
     , Objects.CreatedDate
  from Objects
left outer
  join Views
    on Views.PubID = Objects.PubID
   and Views.ViewBy = 'bdoe'
 where Views.PubID is null

r937.com | rudy.ca
 
That's exactly what I was looking for. thank you very much!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top