Query Help

I want to have a field where I store a list of what categories that
particular row falls under, I don't know which format to do or how I
would query it.

For example, row1 might belong to categories 1, 3 & 7 - I'd want to be
able to query all rows belonging to 3 and get row1.
thesimplerules [ Sa, 26 August 2006 19:06 ] [ ID #1445234 ]

Re: Query Help

thesimplerules [at] gmail.com wrote:
> I want to have a field where I store a list of what categories that
> particular row falls under, I don't know which format to do or how I
> would query it.

When working with a Relational Data Base Management System like
MySql you should use a different approach.

Create a second table where each row consists of two columns;
the row id (from the 1st table) and one of the categories the
row falls in. For each category a row is in the original table
falls in there will be one row in the new table.

>
> For example, row1 might belong to categories 1, 3 & 7 - I'd want to be
> able to query all rows belonging to 3 and get row1.
>
If all you need is the identify of the rows a query against the
new table will provide the answer. If you need the contents of
the row in the original table a join will provide the answer.

If you are not familiar with RDBMS this might seem inefficient
and wasteful -- it isn't! This is because RDBMS are designed to
handle sets of data, but are not very good at splitting out and
working with parts of a "field".

HTH
Jerry
jerry gitomer [ So, 27 August 2006 15:33 ] [ ID #1446038 ]
Datenbanken » mailing.database.mysql » Query Help

Vorheriges Thema: Caching mysql queries
Nächstes Thema: Mrs. Sarah Welsh. (Benefactor)