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
 Transact-SQL (2000)
 Subquery

Author  Topic 

real_pearl
Posting Yak Master

106 Posts

Posted - 2004-06-09 : 05:03:49
Can I treat column's value(data) as column for a subquery. If yes HOW?

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2004-06-09 : 05:31:50
Do you mean as in:

Select * from tablea where id in (select id from tableb)

Go to Top of Page

real_pearl
Posting Yak Master

106 Posts

Posted - 2004-06-09 : 06:04:15
No I mean

select employeeid, first_name, section,
'name' = (select employee.section from employee_personal_info)
from employee

where employee.section's value (data) is the column of employee_personal_info table.
Go to Top of Page

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2004-06-09 : 06:19:51
What's the link between employee and employee_personal_info tables??

If it is employeeid then:-

select e.employeeid, e.first_name, e.section, epi.section as name
from employee e inner join employee_personal_info epi on epi.employeeid = e.employeeid
Go to Top of Page

real_pearl
Posting Yak Master

106 Posts

Posted - 2004-06-09 : 10:54:17
Actually I want to use section's value as FIELD at runtime.

IF section contains Accounts then

SELECT Accounts From Employee_Personal_Info
Go to Top of Page

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2004-06-09 : 11:38:48
Do you know how many value's you will have in section?

If so you could use a case statement...
Go to Top of Page

real_pearl
Posting Yak Master

106 Posts

Posted - 2004-06-10 : 06:35:27
No, I dont know the values of section, its the field of an input screen. so it keeps on increasing.
Go to Top of Page
   

- Advertisement -