连接表并选择不存在的地方

时间:2018-10-19 00:00:02

标签: mysql

我有下表: enter image description here

  

员工:一张我所有员工的桌子
  团队:创建了团队的表格
   team_employees::具有团队与员工列表的关系的表。

因此,基本上,我需要在团队中选择所有没有团队的员工。例如,如果您看到在表team_employees中,id_team#2没有id_employee#2。我要查找的查询选择应该给我ID员工#2(但只给ID#2的团队)

我已经尝试过像这样LEFT JOIN,但是没有运气,因为我认为这会在team_id字段中给我一个NULL,但不是:

SELECT te.id_team AS id_team, e.id, e.name
FROM employees e
LEFT JOIN team_employees te
ON te.id_employee = e.id
WHERE id_team = 2
GROUP BY e.id

感谢您的帮助!

1 个答案:

答案 0 :(得分:2)

使用这种形式的左联接

 System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
 VideoCapture VC = new VideoCapture(0);

//First you requried open Camera.

VC.open();

//Now for geting 'Frame per secand"

VC.get(Videoio.CAP_PROP_FPS); // it returns FPS(Frame per secand)

//Now for seting 'Frame per secand"

VC.set(Videoio.CAP_PROP_FPS,10.0);//in this 10.0 is value for FPS,its double value.
VC.relase();

有时称为“左除联接”。您需要做的是将SELECT te.id_team AS id_team, e.id, e.name FROM employees e LEFT JOIN team_employees te ON te.id_employee = e.id AND te.id_team = 2 WHERE te.id_team IS NULL 放入连接条件中,而不是where子句中。然后使用where子句查找与team表不匹配的所有行。

替代:

e.id_team = 2