List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:April 6 2000 2:19pm
Subject:Re: SELECTing from a SET()
View as plain text  
At 10:01 AM -0400 04-06-2000, Margie Wiers wrote:
>Hello all,
>
>I've checked the Manual, chapter 7, the archives, but can't find how to
>carry out this simple SELECT.  I have a table where one column is
>
>myitems SET("Item1","Item2","Item3" etc).
>
>Of course, each record in the table is different as far as which items and
>how many items the record contains in the myitems column.  But when I try to
>retrieve all the Item1s, for example, the result is an empty set:
>
>mysql> select myitems from mytable
>     -> where myitems="Item1";
>Empty set (0.11 sec)
>
>Because I know that one record in the myitems column contains
>Item1,Item2,Item3, and I query specifically, I get the correct result set:
>
>mysql> select myitems from mytable
>     -> where myitems="Item1,Item2,Item3";
>+---------------------+
>| myitems             |
>+---------------------+
>| Item1,Item2,Item3 |
>+---------------------+
>1 row in set (0.00 sec)
>
>So, how can I write a SELECT so that all the Item1s are retrieved, and only
>Item1s, however they may exist in combination with the other items?

Try:
	WHERE FIND_IN_SET("item1",myitems) != 0

-- 
Paul DuBois, paul@stripped
Thread
SELECTing from a SET()Margie Wiers6 Apr
  • Re: SELECTing from a SET()Paul DuBois6 Apr
  • Re: SELECTing from a SET()Margie Wiers6 Apr
    • Re: SELECTing from a SET()Paul DuBois6 Apr
  • Re: SELECTing from a SET()Margie Wiers6 Apr