Unix Technical Forum

Re: IN & ANY subqueries

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 ...


Go Back   Unix Technical Forum > Database Server Software > MySQL > MySQL General forum

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-27-2008, 10:15 PM
Peter Van Dijck
 
Posts: n/a
Default Re: IN & ANY subqueries

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 09:57 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com