|
Posted by Andy Hassall on 06/09/05 23:57
On 9 Jun 2005 13:45:19 -0700, lkrubner@geocities.com wrote:
>Suppose I have three tables like this:
>
>table weblogEntries{
>
>table keywords {
>
>table whatKeywordsApplyToWhichEntries {
>
>Any time a record in whatPropertiesApplyToWhichEntries has an entryId
>and a keywordId, then that entry has had that keyword assigned to it.
>
>If I wanted to get an entry,
So that's one row.
> along with all keywords that have been applied to it,
That's potentially multiple rows.
So either
* two queries (one for the entry, another for the keywords), or
* end up with repeats in the data returned for the entries fields, from a join
with a the entry-keyword mapping table, one row per keyword.
>if I don't know how many keywords
>have been applied to the weblog entry, what's the syntax of the join?
If you were thinking you can get a variable number of columns out of this, one
per keyword in a single row then forget that idea; that's not how SQL works.
--
Andy Hassall / <andy@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Navigation:
[Reply to this message]
|