get a primary record from a linked table (resolved
I have a DB with the following 2 tables....
EventsTable
EventID -auto number primary key
more fields...
ScheduledEventsTable
ID - foreign key pointing to a record in the Events table
ScheduledDate - date the event should fire
more fields....
I am using the following command string to get all scheduled event between 2 dates and it works...
Code:
Dim cmdString As String = String.Format("SELECT * FROM ScheduledEvents WHERE EventDate BETWEEN #{0}# AND #{1}#", startdate, enddate)
but what I really want is the record from the Events Table that corresponds with the forign key in the ScheduledEvents table.
Can someone help me do this?
I apologies if my terminology isn't right. Although I've be programming since there was dirt, I'm rather new to DB stuff.
thanks
kevin
Re: get a primary record from a linked table
When you ask SQL based questions please tell us the database system you are working with, because it usually makes a difference (in this particular case the difference is minor, but could still cause issues).
To work with more than one table you use a Join, which could be like this:
Code:
SELECT Events.*
FROM Events
INNER JOIN ScheduledEvents ON (Events.EventID = ScheduledEvents.ID)
WHERE ....
If you only want particular fields from the Events table, you should specify them rather than using *
Re: get a primary record from a linked table
thanks a bunch... I was close to it, but off by about 4.32 miles
kevin