Help with SQL query.... I'm sure there is a way!

From: <>
Date: 20 Jun 2006 01:47:58 -0700
Message-ID: <>


I'm helping a friend to build a system to handle advertisments from local dealers in different regions/cities. In this system, an advertisment belongs to a region and is connected to one or more categories (in this context called searchwords).

One of the things that I need to extract is a list of all categories that have 1 or more adds targeted for a specific region. These are the tables:

TABLE regions - contains the regions that a specific add can belong to   id

TABLE adds - contains the advertisements   id
  regionid (corresponds to

TABLE searchwords - contains searchwords that each add can be categorized as

TABLE adds_searchwords - specifies the categories that a specific add belongs to
  addid (corresponds to
  searchwordid (corresponds to

So, from a known I need to get a list of all that have at least one add with a corresponding searchwordid-addid relationship. Is this possible in a single query?

Anyone that can help me?

Björn Received on Tue Jun 20 2006 - 10:47:58 CEST

Original text of this message