[thelist] Basic SQL question

Hassan Schroeder hassan at webtuitive.com
Sat Jan 3 10:07:04 CST 2004


Bob Haroche wrote:

>>SELECT *
>>FROM     Members M,
>>             MembersColors MC
>>WHERE  M.MemberID = MC.MemberID
>>AND       MC.MemberColors IN (red,blue);
> 
> 
> I should elaborate on this over-simplified example. The "colors" will not
> actually be fixed values but will be form
> variables returned in a list of an unknown length. So one form submission
> might return "colors=red,blue,green" while another might return
> "colors=yellow,silver".

But how are you storing them? As
+----------+--------------+
| MemberID | MemberColors |
+----------+--------------+
|        1 | red          |
|        1 | blue         |
|        2 | yellow       |
|        2 | silver       |
+----------+--------------+

or as

+----------+---------------+
| MemberID | MemberColors  |
+----------+---------------+
|        1 | red,blue      |
|        2 | yellow,silver |
+----------+---------------+

Hopefully not the latter, since it violates DB design guidelines
(1NF, First Normal Form) and makes for kludgy queries ...

-- 
Hassan Schroeder ----------------------------- hassan at webtuitive.com
Webtuitive Design ===  (+1) 408-938-0567   === http://webtuitive.com

                           dream.  code.





More information about the thelist mailing list