K
K
kedavr132021-11-22 09:40:42
SQL
kedavr13, 2021-11-22 09:40:42

Select only those records that have one relationship?

There are two tables "employees" and "departments" which have a many-to-many relationship through an intermediate table. I need to get those departments to which only one employee is attached. I can't figure out how to check that an employee of a given department is attached only to him without sorting through the departments of each employee. Interested in an example of a request that will help get an employee tied only to the requested department.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Gornostaev, 2021-11-22
@kedavr13

Make join tables of departments with an intermediate table, group by department and filter by count.

A
Alexey Nikolaev, 2015-03-22
@Heian

Use the form styler and don't waste your time. Redefining plugin styles is as easy as shelling pears, including the way you have.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question