This is a discussion on Re: IN & ANY subqueries within the MySQL General forum forums, part of the MySQL category; --> Or perhaps add a TEXT index to the table? Peter On 9/6/06, Philippe Poelvoorde <pooly7@gmail.com> wrote: > 2006/9/5, Ben ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Or perhaps add a TEXT index to the table? Peter On 9/6/06, Philippe Poelvoorde <pooly7@gmail.com> wrote: > 2006/9/5, Ben Lachman <blachman@mac.com>: > > So possibly a better solution would be to create a temporary table > > and then do a subquery on that table? > > yes. Or do a : > SELECT id FROM t1 WHERE name LIKE '%s1%' OR name LIKE %'s2%' OR name > LIKE '%s3%' > but depending on your data, a table may be the way to go. > > > > > ->Ben > > > > On Sep 4, 2006, at 7:37 AM, Visolve DB Team wrote: > > > > > 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" <blachman@mac.com> > > > 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 > > >> > > > > > > -- > > MySQL General Mailing List > > For list archives: http://lists.mysql.com/mysql > > To unsubscribe: http://lists.mysql.com/mysql?unsub=pooly7@gmail.com > > > > > > > -- > http://www.myspace.com/sakuradrop : forget the rest > http://www.w-fenec.org/ Webzine rock/metal > > -- > MySQL General Mailing List > For list archives: http://lists.mysql.com/mysql > To unsubscribe: http://lists.mysql.com/mysql?unsub=p...ijck@gmail.com > > -- find videoblogs: http://mefeedia.com my blog: http://poorbuthappy.com/ease/ my job: http://petervandijck.net |