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 |
|
cwtriguns2002
Constraint Violating Yak Guru
272 Posts |
Posted - 2007-03-04 : 20:30:58
|
| Hi all. I have the problem on query.This is my query.select D.fullname, P.religion, E.empno from pspersonaldata as Pinner join hremployees as E on P.dcno = E.empdcno inner join psdatacenter as D on D.dcno = E.empdcnowhere P.religion in ('Born Again','Baptist', 'Catholic')How could I make a query that returns a result for either "Born Again, Baptist, or Catholic". The parameter would depend on the input of the user depending on how many religion the user inputed. If the user inputed Born Again and Baptist, the result is the employees that have a religion of Born Again and Baptist.Thanks-Ron- |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
|
|
cwtriguns2002
Constraint Violating Yak Guru
272 Posts |
Posted - 2007-03-04 : 22:32:57
|
| Thanks KH for the time.No. This is another problem. I want to make dynamic report in which the parameters are flexible. I mean, you can enter any number of parameters(Religion) in a fields. For example, in my windows application project, i have checkboxes, and the user will only check the religions he wants to show....be it Born Again, or Baptist, or catholic. Or the user can check all the religion. Is it possible to have a dynamic query for this?Thanks.-Ron- |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-03-04 : 22:52:41
|
[code]select D.fullname, P.religion, E.empno from pspersonaldata as Pinner join hremployees as E on P.dcno = E.empdcnoinner join psdatacenter as D on D.dcno = E.empdcnoinner join CSVTable(@religion) as R on P.religion = R.stringval -- Get CSVTable here[/code]also take a look here KH |
 |
|
|
cwtriguns2002
Constraint Violating Yak Guru
272 Posts |
Posted - 2007-03-05 : 01:07:36
|
| Thanks KH.I have no idea of CSVTable. Im new newbie in SQL and queries.DECLARE @religion varchar (100)SET @religion = 'Born Again, Baptist'select D.fullname, P.religion, E.empno from pspersonaldata as Pinner join hremployees as E on P.dcno = E.empdcnoinner join psdatacenter as D on D.dcno = E.empdcnoinner join CSVTable(@religion) as R on P.religion = R.religionI tried this but it doesnt work. -Ron- |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-03-05 : 01:12:19
|
[code]DECLARE @religion varchar (100)SET @religion = 'Born Again, Baptist'select D.fullname, P.religion, E.empno from pspersonaldata as Pinner join hremployees as E on P.dcno = E.empdcnoinner join psdatacenter as D on D.dcno = E.empdcnoinner join CSVTable(@religion) as R on P.religion = R.stringval[/code]You have to get the CSVTable function from the link that i provided. KH |
 |
|
|
cwtriguns2002
Constraint Violating Yak Guru
272 Posts |
Posted - 2007-03-05 : 02:24:30
|
| Thanks KH. It works fine.-Ron- |
 |
|
|
|
|
|
|
|