Ahmed Hassan Ahmed Hassan - 1 year ago 72
SQL Question

SQL query condiction help please

I have three tables

Users ( ID - Name )
Services (ID - Name)
UserServices ( ID - USerID- ServiceID )

I want to select serviceName that not belong to user
if i have three users and 10 services

First user belong to 3 services so i want to select other 7 services only


Answer Source

There is many way to get the results you want, this is one :

FROM  UserServices AS US
INNER JOIN Services AS S ON US.ServiceID = S.ID
WHERE US.UserID <> @UserID
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download