0

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..

4

2 回答 2

0

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

于 2012-07-09T09:25:18.813 回答
0

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 ;
于 2012-07-09T09:28:10.813 回答