[thelist] Query Help
thelist at cjmarsh.com
thelist at cjmarsh.com
Thu Jan 5 14:42:40 CST 2006
Casey
> > SELECT DISTINCT events_banquets.event_id
> > WHERE events_banquets.event_id = events_banquets_staff.event_id
> > AND events_banquets_staff.userID = '" & userID & "' "
>
> Thanks Chris.... but, can you use a table in the WHERE clause
> when you
> didn't use it in the SELECT? I now get this error:
You certainly can, but you *do* need the FROM clause that I inadvertently
deleted :)
Try the following:
SELECT DISTINCT events_banquets.event_id
FROM events_banquets,
events_banquets_staff
WHERE events_banquets.event_id = events_banquets_staff.event_id
AND events_banquets_staff.userID = '" & userID & "' "
Personally I would be inclined to use the following syntax:
SELECT DISTINCT events_banquets.event_id
FROM events_banquets_staff ebs
INNER JOIN events_banquets eb
ON eb.event_id = ebs.event_id
WHERE ebs.userID = '" & userID & "' "
There is no particular performance gain that I'm aware of, but I find it a
lot easier to see what I'm doing with this syntax.
HTH!
[..]
Regards
Chris Marsh
--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.371 / Virus Database: 267.14.11/219 - Release Date: 02/01/2006
More information about the thelist
mailing list