Query Help

Query Help

am 26.08.2006 19:06:34 von thesimplerules

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.

Re: Query Help

am 27.08.2006 15:33:20 von jerry gitomer

thesimplerules@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