I have a table named platform_Users
and other table Assigned_Users
.
I want MSSQL sp "getAllUnAssignedUSER
" which get all users records from platform_user
which are not inserted in Assigned_User
..
I have a table named platform_Users
and other table Assigned_Users
.
I want MSSQL sp "getAllUnAssignedUSER
" which get all users records from platform_user
which are not inserted in Assigned_User
..
left join the tables together
Then in the where clause return where Assigned_Users.UserID is null
Should return all records from 1st table where they have no joined entry in the assigned table
Try this
DELIMITER $$
CREATE
PROCEDURE `getAllUnAssignedUSER`()
BEGIN
SELECT * FROM platform_Users pu WHERE pu.id NOT IN (SELECT DISTINCT id FROM Assigned_Users);
END$$
DELIMITER ;