Hi

The ANY keyword, which must follow a comparison operator, means "return TRUE if 
the comparison is TRUE for ANY of the values in the column that the subquery 
returns

In has 2 forms:
1.  IN (subquery).  [The word IN is an alias for = ANY (subquery)].
2. IN (list of values seperated by comma)

Hence the exact syntax to use is:
Select <fields> from < table> where <fieldname> = ANY ( select <fieldname> from 
<table>);

Ref: http://dev.mysql.com/doc/refman/5.0/en/any-in-some-subqueries.html

Thanks
ViSolve DB Team

----- Original Message ----- 
From: "Ben Lachman" <[EMAIL PROTECTED]>
To: <mysql@lists.mysql.com>
Sent: Sunday, September 03, 2006 10:33 AM
Subject: IN & ANY subqueries


>I have a string comparison that I would like to do against a short  
> list of constant strings.
> 
> at the moment I am using the syntax
> 
> SELECT id FROM t1 WHERE name IN('s1', 's2', 's3', ...);
> 
> However, this limits me to exact matches and I'd like to move to a  
> caparison expersion that lets me match names that contain any of the  
> list.  The MySQL docs state that 'IN()' is an alias to '= ANY()'  
> however when I substitute' = ANY' for IN I get a parse error.  What  
> I'd like to do is write something like (although I figure there may  
> be a better way to do the comparison that I am not thinking of):
> 
> SELECT id FROM t1 WHERE name LIKE ANY('%s1%', '%s2%', '%s3%', ...);
> 
> Does anyone know a way to do this?
> 
> Thanks,
> 
> ->Ben
> 
>

Reply via email to