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.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2005-09-26 : 07:55:47
|
| Deppah writes "Hi,I am writing a search stored procedure for a web page.It has a listbox where the user selects multiple values.I need to implement logic to be able to return results based on all the values selected in the listbox. So basically I need to do AND operation for all the values selected in listbox.heres an example:Table 1 - TestID, Name1, "Name1"2,"Name2"Table 2- contains the list box values for the TestIDsTestID,ListboxValue1,"A"1,"B"2,"A"2,"B"2,"C" ...now on the search screen the user selects "A" and "B" from the listbox.How do I display only TestID 1 in the result as they want to only see records that have the records for ALL the values selected. So testID = 2 should not come up as it also has value "C" in Table 2.I am sending in the values of listbox as a comma separated list (as parameter) to the stored procedure.Hope this makes some sense!Thanks very much in advance,Deppah" |
|
|
SqlStar
Posting Yak Master
121 Posts |
Posted - 2005-09-26 : 19:03:14
|
| Use dynamic sql with IN operator... (You should frame IN operater with values and send that to your stored procedure and build dynamic sql and execute that)Rafiq~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"You have to dream before your dreams can come true" -- President Of India |
 |
|
|
|
|
|