Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

VB.net SQL statement where column is  any of an item in a list

Posted on 2014-02-12
2
Medium Priority
?
333 Views
Last Modified: 2014-02-12
Hi
I have a variable in VB.net that contains a list of string items separated by commas
eg "Canada,USA,Australia"
How do I build a SQL Where clause to brings up anything in this list?
0
Comment
Question by:Murray Brown
2 Comments
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 2000 total points
ID: 39852906
you can add quotes and use the IN clause:

sql = "select * from YourTable where country in ('" + YourVariable.Replace(",", "','") + "')"
0
 

Author Closing Comment

by:Murray Brown
ID: 39852961
Thanks very much
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Windocks is an independent port of Docker's open source to Windows.   This article introduces the use of SQL Server in containers, with integrated support of SQL Server database cloning.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Viewers will learn how the fundamental information of how to create a table.

876 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question