i have Multiple Role ID For Single Emplyee with different rows. I want to check each roleid exist or not in another table with different rows
Loading
i have Multiple Role ID For Single Emplyee with different rows. I want to check each roleid exist or not in another table with different rows
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Brahma Prakash ShuklaPosted Aug 14, 2023, 2:26 PM
Assuming you have the following two tables:
Table
EmployeeRoles:Table
AvailableRoles:You want to check if each RoleID associated with an EmployeeID in the
EmployeeRolestable exists in theAvailableRolestable.Here's a SQL query that can help you achieve this:
This query uses a LEFT JOIN between the
EmployeeRolesandAvailableRolestables on theRoleIDcolumn. It selects theEmployeeIDandRoleIDcolumns from theEmployeeRolestable and checks whether a match is found in theAvailableRolestable. If a match is found (RoleID exists), the RoleStatus column will show "Exists"; otherwise, it will show "Not Exists".Keep in mind that the above query assumes that you want to check all role IDs for each employee. If you want to check only specific role IDs or employees, you can modify the query accordingly using WHERE clauses.
Please replace table and column names with your actual table and column names if they are different in your database.
Amit MohantyPosted Aug 16, 2023, 5:44 AM
Abhishek YadavPosted Aug 16, 2023, 5:13 AM
Tasadduq BurneyPosted Aug 15, 2023, 7:45 AM
Cr BhargaviPosted Aug 15, 2023, 3:25 AM