2

I need to find the number of employees who are not in all departments.

I have one more table T2 in which same department column is present. Now I want to insert only those values of department which are not in T1.Department for those employees whose name doesn't appear in all 37 departments.

I'm using MySQL.

Do I need to make any procedure for this?

Reference to : Need to find the number of employee who are not in all department

Tables

create table T1 (empname, department)
create table T2 (department)
  • Post your table definitions. One query like insert into ... select .... where .... should do the job; no need for procedure. – a1ex07 Jul 11 '13 at 13:30
1

You can insert the result of a SELECT using INSERT ... SELECT syntax. To get rows from one table that do not have corresponding rows in another you can use the A not in B LEFT JOIN MySQL idiom or a similar one with NOT EXIST subquery (though the latter is less efficient).

Please give your table details for more specific query.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.