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

From: <bjorn.bergstrom_at_jadestone.se>
Date: 20 Jun 2006 01:47:58 -0700
Message-ID: <1150793277.523966.290680_at_h76g2000cwa.googlegroups.com>



Hi,

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
  name

TABLE adds - contains the advertisements   id
  regionid (corresponds to regions.id)
  text

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

TABLE adds_searchwords - specifies the categories that a specific add belongs to
  addid (corresponds to adds.id)
  searchwordid (corresponds to searchwords.id)

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

Anyone that can help me?

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

Original text of this message