Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Help With JOIN Statements

5:11 am on Mar 24, 2005 (gmt 0)

Junior Member

10+ Year Member

joined:Feb 24, 2003
votes: 0

I think I need some help with implementing a JOIN statement. I have a situation where I have 2 tables: "events" & "photos". Events has 2 fields: "eventID", "name" and photos has 3 fields: "photoID", "filename" and "eventID". I need to create a select statement that will return events.eventID for events that appear in the eventID column of the photos table. All the JOIN statements I've used return a result for every record in the photos table that has an eventID, so that a query gives me 20 instances of events.eventID for every photo that is in the photos table.

My goal is to create a list of events that have photos associated with them, but instead I'm getting the events for every photo in the table. How should I construct my SQL statement?

11:06 am on Mar 24, 2005 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month

joined:July 24, 2002
votes: 0

hi terry

sounds like a left join

select whatever
from events
left join photos
on events.eventID = photos.eventID

there's an excellent tutorial in w3schools which explains joins very clearly.



Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members