On Sat, 13 Mar 2004 15:34:28 GMT, Jack <no*****@please.com> wrote:
One of my database tables fields sometimes contains two items. They are
input into the field as "item1, item2" (no quotes). The query I'm using
doesn't seem to pick up any of these multiple items. I'm using
SELECT * FROM table WHERE category = 'item2'
This works fine when item2 is the only thing in the field but not when
it's shared with another value. How can I make the query find all the
instances of item2 in the field even when there are more than one value
in some of the entries?
Preferably by fixing your database layout. One field should contain one value.
i.e.
Item
----
item_id
category
Containing:
item_id | category
--------+--------------
1 item1, item2
... is wrong. It should be something like:
Item
----
item_id
Containing:
item_id
-------
1
... and a second table:
ItemCategory
------------
item_id
Containing:
item_id | category
--------+--------------
1 item1
1 item2
--
Andy Hassall <an**@andyh.co.uk> / Space: disk usage analysis tool
<http://www.andyh.co.uk> / <http://www.andyhsoftware.co.uk/space>