Click here to Skip to main content
15,899,679 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,


I have used a query like that.

SQL
SELECT *,convert(varchar,DOJ,103) as DateOJ FROM Registration_Mstr R,Designation_Mstr D,Department_Mstr DP where R.DesgId=D.DesgId and DP.DepartmentId=R.DepartmentId and  EmployeeStatus=1 and (D.Designation<>'Administrator' or D.Designation<>'Directors') order by EmployeeName



In this I do not want to populate information of employees whose designation are Administrator and Directors.
But still it is showing information.
Please help if I am wrong somewhere .


Thanks
Mohd. Wasif
Posted

Don't use OR. Use AND only. D.Designation<>'Administrator' AND D.Designation<>'Directors'
 
Share this answer
 
Comments
Monjurul Habib 5-Sep-11 14:59pm    
nice advice, but "NOT IN" is better..my 5
Another way of saying this in SQL is to use IN-lists. They may sometimes be more easy to interpret:
SQL
SELECT *,convert(varchar,DOJ,103) as DateOJ 
FROM Registration_Mstr R,
     Designation_Mstr  D,
     Department_Mstr   DP 
where R.DesgId        = D.DesgId 
and   DP.DepartmentId = R.DepartmentId 
and   EmployeeStatus  = 1 
and   D.Designation   NOT IN('Administrator','Directors') 
order by EmployeeName
 
Share this answer
 
Comments
Monjurul Habib 5-Sep-11 14:57pm    
yes NOT IN is better..my 5++..proposed as best answer.
Wendelius 5-Sep-11 15:03pm    
Thank you.
You need to use and
SQL
D.Designation<>'Administrator' or and D.Designation<>'Directors'
 
Share this answer
 
Comments
Toniyo Jackson 5-Sep-11 8:11am    
You beat me to it. 5!
Prerak Patel 5-Sep-11 8:13am    
Thanks TJ :)
Mohd Wasif 5-Sep-11 8:13am    
Thanks Dear
My +5
Prerak Patel 5-Sep-11 8:14am    
You are welcome. If your query is solved, mark the answers.
Monjurul Habib 5-Sep-11 14:59pm    
nice advice, but not in is better..my 5

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