Query Help

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
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

thesimplerules@gmail.com wrote:
Quoted text here. Click to load 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.

Quoted text here. Click to load it
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".


Site Timeline