Click here to Skip to main content
15,892,809 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I am designing a webpge using asp.net with sql server 2005
in back end there is table with followding columns
username,name,phone1,phone2,age and some others columns are there for storing user's details.

I would like to select in such a way so that i enter

more than one user name seperated with commas in textbox
in selection result i get all the phone numbers associated with that usernames.

For example

Usernames Name Phone1 Phone2
abc@yahoo.com Abhi 9334459287 9334459288
def@yahoo.com Sony 9935199351
efg@yahoo.com Tony 9835198351 9835198351


Select Phone1,Phone2 from tblregistration where usernames=abc@yahoo.com,def@yahoo.com,efg@yahoo.com


In result i like all the phone numbers
9334459287 9334459288
9935199351
9835198351 9835198351

Please help me.
Posted
Updated 25-Dec-14 18:05pm
v2

 
Share this answer
 
build sql statement with multiple usernames as where conditions.
for example if user input 3 usernames
SQL
select tp1, tp2 from table1 where username =@username1 or username =@username2 or username = @username3

you may need to split user input and get each user name like below when you set parameter values
string input ="abc@yahoo.com,def@yahoo.com,efg@yahoo.com";
string[] usernames =input.Split(',');
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900