Hello,

I am using sql server database. I have this select statement and would like to ask one question about this:

tbl_student
ID Dept Name
-----------------
1 A jenny
2 B beta
3 C jim
4 D kim
5 B beta
6 C jim

qry_student
select distinct Name from tbl_student where Name in ('jenny','beta','jim')

Output:
Name
-----
jenny
beta
jim

On ASP page, I use this statement:
select Name from student where Name='jenny' OR Name='beta' OR Name='jim'

It works.

When I do dynamically by using this statement:
select Name from student where Name IN ('select Dept from qry_student')

It does not work. I am trying to return the value of the Name in either (jenny, beta, or jim) but it does not return the value.

How do I change this statement to make it work dynamically?
select Name from student where Name IN ('select Dept from qry_student')

Thanks.