[thelist] [sql] location of conditional
Joshua Olson
joshua at waetech.com
Mon Aug 4 21:07:11 CDT 2003
Hey SQL geeksters,
Assume 2 tables holding categories and items. Assume item has a field
category_id which designates which category that item is in. There are lots
of ways to query all the non-deleted products is a specific category, but
given the follow two versions, why/when would you want to prefer one over
the other? (notice the location of the AND category_id = 5)
SELECT item.name
, item.price
, category.name AS category_name
FROM item
INNER
JOIN category
ON category.id = item.category_id
WHERE item.is_deleted = 0
AND category_id = 5
---- or ----
SELECT item.name
, item.price
, category.name AS category_name
FROM item
INNER
JOIN category
ON category.id = item.category_id
AND category_id = 5
WHERE item.is_deleted = 0
Thanks in advance.
<><><><><><><><><><>
Joshua Olson
Web Application Engineer
WAE Tech Inc.
http://www.waetech.com
706.210.0168
More information about the thelist
mailing list