View Single Post
Old 07-01-2007, 11:01 PM   #2
Captain Paralytic
 
Captain Paralytic's Avatar
 
Posts: n/a
My Photos: ()

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default How do I parse a comma separated field?

On 14 Jun, 15:03, "John Rappold" <jrapp...@jscoca-k12.org> wrote:
> I have a table with the following fields:
> tableid (int)
> userid (varchar)
> lvalues (varchar)
>
> the lvalues column contains comma separted values. e.g. 12, 5, 32
> each individual values matches a field in another table.
>
> How do I write a SQL query that parses the comma separated data? For
> example:
> WHERE user id=30 so that the results look like:
>
> 30 | 12
> 30 | 5
> 30 |32
>
> TIA


You don't you build a table structure where each value has its own
record in another table.

From: http://dev.mysql.com/tech-resources/...alization.html
"The first normal form (or 1NF) requires that the values in each
column of a table are atomic. By atomic we mean that there are no sets
of values within a column."

  Reply With Quote