SQL IN operator string builder

Have you ever had a list in excel, that you need to query from a database? Something like this:

abc

def

ghi

jkl

mno

Then you had to turn it into a SQL query like this:

Select * from mytable where some_value in (’abc’,'def’,'ghi’,'jkl’,'mno’)

Yeah…not so bad when its four or five…or you don’t work on a trading floor where a trader is down your neck wanting an answer immediately. Well I solved the problem. The following script will turn a comma/space/custom delimited list into a perfect string you can use in SQL.

If you’d like to run this on your own server or edit it. Contact me and I will gladly send you the source code.

http://www.gregjessup.com/scripts/SQL/

About the Author

Greg

Leave a Reply

You can use these XHTML tags: <a href="" title=""> <abbr title=""> <acronym title=""> <blockquote cite=""> <code> <em> <strong>


Warning: stristr() [function.stristr]: Empty delimiter in /home/thegard5/public_html/gregjessup/wp-content/plugins/wassup/wassup.php on line 2093