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
 MSSQL Query Merging...?

Author  Topic 

Paul Skinner
Starting Member

9 Posts

Posted - 2007-05-02 : 18:08:21
I have this database running (ignore that that was done in Access, this is being made in Microsoft SQL Server 2005).


What I need to do is if you look at the tbl_events table and the tbl_timekeeperDetails table I need to make a query that:

Lists the names of all timekeepers (whether they are booked for a meeting or not), and the meetings at which they are timekeeping.

The tricky part of this is getting the query to show the timekeepers who aren't assigned to an event.

I have two seperate querys so far, but I'm presuming there must be a way of merging them or something.

I have this code so far:
select timekeeperTitle,timekeeperNameFirst,timekeeperNameLast,eventID
from timekeeperDetails,events
where timekeeperDetails.timekeeperID = events.timekeeperID
select timekeeperTitle,timekeeperNameFirst,timekeeperNameLast
from timekeeperDetails

If anyone has any ideas, please do post a reply or email me at paul [at] abscond [dot] org

It would be very much appreciated.

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-05-02 : 18:15:04
select d.timekeeperTitle, d.timekeeperNameFirst, d.timekeeperNameLast, e.eventID
from timekeeperDetails as d
left join events as e on e.timekeeperid = d.timekeeperid


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

Paul Skinner
Starting Member

9 Posts

Posted - 2007-05-02 : 18:18:57
Any chance of a very quick explanation of how that works?

And thank you very much.
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-05-03 : 05:18:23
how left join works?

left join returns all data from the left table and nulls for the data that don't have a relationship in the right table.

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
Go to Top of Page
   

- Advertisement -