You are here: Re: an SQL join question which I can not figure out « PHP Programming Language « IT news, forums, messages
Re: an SQL join question which I can not figure out

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация