[thelist] How do I properly query multiple tables?
Brian Cummiskey
Brian at hondaswap.com
Wed Feb 9 16:55:21 CST 2005
Pringle, Ron wrote:
>
> I first want to check the eventDates table and compare the eventDate field
> to a querystring that is passed to the ASP page.
ok, so the first thing you want to do is grab the date from the
querystring and make it a local var to make things easier to read
EDate = CDate(Request.QueryString("EventDate"))
good.
> Then I want to grab all event records that match that date and link the
> records together from all tables based on a primarykey field of eventID.
select * from tbl_event EV
join tbl_eventdates ED
on EV.eventID = ED.eventID
-->//// now do the same join for the other tables...
join tbl_contact C
on EV.eventID = C.eventID
join tbl_link L
on EV.eventID = L.eventID
where EV.eventdate = EDate
>
> Some of the tables will have no values stored in them, as those fields are
> optional.
that's fine. if the event ID doesn't have a link or whatever for that
ID, that field will simply be blank- but as long as the EDate matches 1
other, you will get a record row.
HTH
More information about the thelist
mailing list