MySQL Forums
Forum List  »  Stored Procedures

WHERE col_name IN(....)
Posted by: Michael Dunn
Date: February 10, 2006 04:36PM

This may not be possible, or possible using a different method, however, I'd like to send in a comma separated list of possible values, for instance i've got a keyword table, my customer searches for something like 'Hello World' I'd like to be able to make the statement WHERE keyword IN('Hello', 'World'). Obviously from PHP this is easy if i create the entire statement. Howerver is it possible to send in Hello and World a preset list and end up with some like

CREATE PROCEDURE `keywordsearch`(keyword_list VARCHAR(150))
BEGIN
SELECT * FROM keywords
WHERE keyword_txt IN(keyword_list);
END

then send it a list like "'hello','world'".

Now i should say that the above is leagal, and will work if I send it "hello" by it self, or "world" by it self, but then flunks when I send it the two together. I'm sure because it's treating it as an entire string.

Options: ReplyQuote


Subject
Views
Written By
Posted
WHERE col_name IN(....)
4408
February 10, 2006 04:36PM
2402
February 11, 2006 12:47PM
1686
February 13, 2006 11:02AM
1778
February 13, 2006 01:52PM
1891
February 13, 2006 05:02PM
1838
February 13, 2006 06:16PM
1889
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.