MySQL Forums
Forum List  »  Stored Procedures

Re: WHERE col_name IN(....)
Posted by: Roland Bouman
Date: February 11, 2006 12:47PM

use FIND_IN_SET (http://dev.mysql.com/doc/refman/5.0/en/string-functions.html)

if you want to send in the list as a string:

SELECT * FROM keywords
WHERE find_in_set(keyword_txt,keyword_list);

however, if you've got all the words in a separated for to begin with, you'd better use that:


SELECT * FROM keywords
WHERE keyword_txt IN ('Hello','World');

Of course, the list must be specified when you create a procedure, so I´d probably generate the statement on the fly in the php script (if i was calling it from php).

ALthough it is true that one can use native dynamic sql (as opposed to generating the statemen on the client sid) using the PREPARE syntax (http://dev.mysql.com/doc/refman/5.0/en/sqlps.html), this does not do you much good, because you still need to be able to pass a variable length list (an arry or so) to the procedure (wich is presently not possible)

Options: ReplyQuote


Subject
Views
Written By
Posted
4568
February 10, 2006 04:36PM
Re: WHERE col_name IN(....)
2548
February 11, 2006 12:47PM
1773
February 13, 2006 11:02AM
1851
February 13, 2006 01:52PM
1970
February 13, 2006 05:02PM
1911
February 13, 2006 06:16PM
1993
February 14, 2006 04:19PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.