dougezhua0017 2016-01-06 14:50
浏览 11
已采纳

选择不在特定团队中的所有用户

I want to select all users from the database that is not within the particular team ID I'm looking at. Trying to make an 'add a member' function which is supposed to list all members that are not in the active team.

I just can't seem to get the SQL right.. Either I get nothing, or I still get some members that are within the active team and others, which I don't want.

This is the database, IMGUR

So in this case, viewing team ID 77 on the website, I wanna see only "Admin", as he is the one member that is not within that particular team.

Any help would be much appreciated.

  • 写回答

4条回答 默认 最新

  • douyao1856 2016-01-06 15:03
    关注

    I think this is what you need:

    SELECT *
    FROM User
    WHERE userid NOT IN (
        SELECT userid
        FROM UserTeam
        WHERE teamid = ...
    )
    

    It returns all users except those in the specific team.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥50 mac mini外接显示器 画质字体模糊
  • ¥15 TLS1.2协议通信解密
  • ¥40 图书信息管理系统程序编写
  • ¥20 Qcustomplot缩小曲线形状问题
  • ¥15 企业资源规划ERP沙盘模拟
  • ¥15 树莓派控制机械臂传输命令报错,显示摄像头不存在
  • ¥15 前端echarts坐标轴问题
  • ¥15 ad5933的I2C
  • ¥15 请问RTX4060的笔记本电脑可以训练yolov5模型吗?
  • ¥15 数学建模求思路及代码