Query Help

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • thesimplerules@gmail.com

    #1

    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.

  • Jerry Gitomer

    #2
    Re: Query Help

    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

    Comment

    Working...