DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   VB.NET (http://www.daniweb.com/forums/forum58.html)
-   -   SQL (http://www.daniweb.com/forums/thread201580.html)

kimbula... Jul 4th, 2009 1:17 am
SQL
 
Hi all,
I need a favor on SQL this time

There are 4 tables as follows

Employee(EmpID,EmpName,...........)
Designation(Des_ID,Designation....)
EmpProfInfo(EmpID,Des_ID,..........)
Training(TrainingTypeID,EmpID,TrainingType,.......)

When an employee allocated to a training their details will be inserted in to the Training Table

I want to write a sql query so that I can select EmpID,EmpName,Designation of employees who do not participated in the particular training type

It would be a great help if anyone could show me a way to achieve this

GeekByChoiCe Jul 4th, 2009 4:10 am
Re: SQL
 
Im only in MYSQL but this might also works in MSSQL

SELECT * FROM Employee WHERE Employee.EmpID NOT IN (SELECT EmpID FROM Training WHERE TrainingType=0);

samir_ibrahim Jul 4th, 2009 4:28 am
Re: SQL
 
Try this

SELECT Training.EmpID, Training.TrainingType, Employee.EmpName, EmpProfInfo.Des_ID, Designation.Designatio
FROM Designation RIGHT OUTER JOIN
Employee RIGHT OUTER JOIN
EmpProfInfo RIGHT OUTER JOIN
Training ON EmpProfInfo.EmpID = Training.EmpID ON Training.EmpID = Employee.EmpID ON Designation.Des_ID = EmpProfInfo.Des_ID
WHERE (Training.TrainingType <> 'Type1')


All times are GMT -4. The time now is 11:29 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC