gpt4 book ai didi

mysql - 不喜欢来自两个表

转载 作者:行者123 更新时间:2023-11-29 12:35:56 24 4
gpt4 key购买 nike

我正在尝试从表 A 中获取具有特定 MeetingID 的表 B 中不存在的所有用户名就像 iam 尝试获取 Meetingid: 2 一样,表 A 应该返回“Tested”用户,并将其余内容排除在外。 MeetingID 6 返回测试。这可以通过一个查询实现吗?

Table A: ID, Username 1 Test 2 Tested 3 Testood

Table B: Meetingid, Username 2 Test 2 Testood 6 Tested 6 Testood

这是我一直在尝试工作的代码:

SELECT members.username FROM members RIGHT JOIN attendmeeting ON
attendmeeting.username=members.username WHERE attendmeeting.username
NOT LIKE members.username ORDER BY username DESC

表 A 是成员,表 B 是出席 session 。我不知道如何根据 session ID 过滤掉它。

================================================== =====

编辑:感谢 Harsh Gupta,第一部分现在正在工作。最后一件事是过滤掉“不喜欢”仅对这些成员使用特定的 session ID。

当前代码:

SELECT members.username 
FROM members
LEFT JOIN attendmeeting
ON attendmeeting.username = members.username
WHERE attendmeeting.username IS NULL
ORDER BY members.username DESC

最佳答案

我不确定您的 tableA 和 tableB 是哪一个:

SELECT members.username 
FROM members
LEFT JOIN attendmeeting
ON attendmeeting.username = members.username
WHERE attendmeeting.username IS NULL
ORDER BY members.username DESC

编辑:

SELECT members.username 
FROM members
LEFT JOIN attendmeeting
ON attendmeeting.username = members.username
WHERE attendmeeting.username IS NULL
AND attendmeeting.username = 2
ORDER BY members.username DESC

HTH

关于mysql - 不喜欢来自两个表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26798542/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com