RE: [PHP-DB] Re: enum !!

From: Date: Mon, 16 Jul 2001 19:39:55 +0000
Subject: RE: [PHP-DB] Re: enum !!
Groups: php.db 
Request: Send a blank email to php-db+get-10461@lists.php.net to get a copy of this message
> -----Original Message----- > From: McShen [mailto:hshen@crosswinds.net] > Sent: Monday, July 16, 2001 1:56 PM > To: php-db@lists.php.net > Subject: Re: [PHP-DB] Re: enum !! > > > ok. I use set to make a table. here is my table 'test' > +-------+------+ > | name | cat | > +-------+------+ > | shen | a,c | > | shen1 | b,c | > +-------+------+ > > How can I find all records that contain 'c'? > i tried > select * from test where cat='c'; > > it returned "empty set"; Quoting from http://www.mysql.com/doc/S/E/SET.html Normally, you perform a SELECT on a SET column using the LIKE operator or the FIND_IN_SET() function: mysql> SELECT * FROM tbl_name WHERE set_col LIKE '%value%'; mysql> SELECT * FROM tbl_name WHERE FIND_IN_SET('value',set_col)>0; But the following will also work: mysql> SELECT * FROM tbl_name WHERE set_col = 'val1,val2'; mysql> SELECT * FROM tbl_name WHERE set_col & 1; The first of these statements looks for an exact match. The second looks for values containing the first set member. --- Mark Roedel | "The most overlooked advantage to owning a Systems Programmer | computer is that if they foul up there's no LeTourneau University | law against whacking them around a little." Longview, Texas, USA | -- Owen Porterfield

« previous php.db (#10461) next »