SELECT DISTINCT
(di.id)
FROM directoryitem di,
location l,
contactinfo ci,
directoryitemtags dit
WHERE di.contactInfoId = ci.id
AND l.id = ci.locationId
AND dit.directoryItemId = di.id
AND dit.tagId in (373, 123, 456) --this section can be made dynamic with a variable
AND l.countryId = 225
ORDER BY di.businessName ASC





by: BadotzPosted on 2009-08-16 at 08:08:49ID: 25109217
This excludes all of your tags:
AND (dit.tagId = 342 AND dit.tagId = 373)
Why? Because "dit.tagId" cannot be equal to two things at once.
This might work:
AND (dit.tagId = 342 OR dit.tagId = 373)