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))
SELECT * FROM keywords
WHERE keyword_txt IN(keyword_list);

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

Written By
WHERE col_name IN(....)
February 10, 2006 04:36PM
February 11, 2006 12:47PM
February 13, 2006 11:02AM
February 13, 2006 01:52PM
February 13, 2006 05:02PM
February 13, 2006 06:16PM
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.