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 |
|
yosiasz
Master Smack Fu Yak Hacker
1635 Posts |
Posted - 2008-06-17 : 18:03:01
|
| Hi there,I have three tablesJob JobID WeightIn WeightOutOperator OperatorID NameFirst NameLastJobOperator JobOperatorID JobID OperatorIDa job can be done with 1 or more operatorsI want to be able to show user both assigned and unassigned operator on the front end on a certain job so I haev only parm being passed in @jobID.How do I got about showing all the operators but somehow differentiate ones already assigned to jobThanks! |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
yosiasz
Master Smack Fu Yak Hacker
1635 Posts |
Posted - 2008-06-17 : 18:08:37
|
| Will this work?SELECT [Operator] = OperatorFirstName + ' ' + COALESCE(OperatorMiddleName,'') + ' ' + OperatorLastName, vo.OperatorID AS KeyField , hidSelectedYesNo = ( SELECT CASE WHEN COUNT(*) > 0 THEN 1 ELSE 0 END FROM VJobOperators vjo WHERE vjo.JobID = @JobID AND vjo.OperatorID = vo.OperatorID) FROM dbo.VOperators AS vo |
 |
|
|
yosiasz
Master Smack Fu Yak Hacker
1635 Posts |
Posted - 2008-06-17 : 18:09:00
|
| oops I meant to saySELECT DISTINCT [Operator] = OperatorFirstName + ' ' + COALESCE(OperatorMiddleName,'') + ' ' + OperatorLastName, vo.OperatorID AS KeyField , hidSelectedYesNo = ( SELECT CASE WHEN COUNT(*) > 0 THEN 1 ELSE 0 END FROM VJobOperators vjo WHERE vjo.JobID = 1 AND vjo.OperatorID = vo.OperatorID) FROM dbo.VOperators AS vo |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
yosiasz
Master Smack Fu Yak Hacker
1635 Posts |
Posted - 2008-06-17 : 18:26:02
|
| Yes Almighty Goddess I tried it and it does work :O) That is what I meant to say I apologize. |
 |
|
|
|
|
|