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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

A question about joins...

Status
Not open for further replies.

Mayoor

Programmer
Jan 16, 2004
198
GB
I am joining 3 tables together although when there are no matching results in the contributor table nothing is retuned for the whole record set.

I would like the firstname and lastname to just say null if there is nothing in them. Can anyone help?

Code:
SELECT 
	E.EventID, 
	E.Title, 
	E.BriefDescription, 
	E.Description, 
	E.ThumbnailImageID, 
	E.ImageID, 
	E.StartDateTime, 
	E.EndDateTime, 
	E.Cost, 
	E.EventTypeID, 
	E.isAdults, 
	E.isChildren, 
	E.InsertedBy, 
	E.InsertedDate,
	C.FirstName,
	C.LastName

FROM 
	Event AS E

LEFT JOIN 	
	EventContributor AS EC
ON	EC.EventID = E.EventID	

LEFT JOIN 	
	Contributor AS C
ON	EC.ContributorID = C.ContributorID

WHERE 	EC.EventID = 3
 
Sorry I forgot to mention that that is usually parameter driven I have substituted 3 in just for test purposes.

Incidently there are 5 records in the Event table but only one record in the EventContributor table which matches.

There may not necessarily be a contributor for an event.

My aim is to output the event and any contributors (firstname and lastname) if there are any, if not then just want thhe firstname and lastname fields to have null in them.

Thanks!
 
well bugger me its fixed! Thanks James!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top