Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 multiple value query

Author  Topic 

alxtech
Yak Posting Veteran

66 Posts

Posted - 2006-02-02 : 09:08:40
Problem:
In a web form (vb.net) multiple selection from list box is allowed,

Category List box

sports
news

arts
culture
elections
night life

three item selected: sports,news,culture

I am getting a string value from all selected choices like this:

Dim listofstrings As String
Dim item As ListItem

For Each item In listbox.Items
If item.Selected Then
listofstrings = listofstrings & item.Text & ","
End If
Next

so i have listofstrings = (selectedvalue1,selectedvalue2,selectedvalue3,.......)

I need to select all values from a table in database (sql2000) where any of those values corresponds.

NOTE: Values in database can also be in the format of (value1,value2,value3,......) or just a single (value1,)

szgldt
Starting Member

10 Posts

Posted - 2006-02-02 : 09:21:13
If I understand the issue then you could use the IN Clause.

Your query would be similar to the following

SELECT *
FROM TableName
WHERE Category IN ('sports','news', 'culture')
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-02-02 : 09:29:11
Also search for where in @MyCSV in this topic
http://sqlteam.com/forums/topic.asp?TOPIC_ID=55210


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -