gpt4 book ai didi

mysql 比较两个表以查找匹配的记录

转载 作者:行者123 更新时间:2023-11-29 04:18:18 25 4
gpt4 key购买 nike

我正在尝试从 tbl_attn_temp 获取所有数据,其中 TraineeIDtbl_assigned TraineeIDtbl_instructor_info InstructorID。但我得到的所有数据都与 tbl_assigned TraineeID 匹配。 tbl_instructor_info 数据未显示或显示如下:

tbl_attn_temp

enter image description here

tbl_assigned

enter image description here

tbl_instructor_info

enter image description here

SELECT t1.*
FROM tbl_attn_temp t1, tbl_instructor_info t2, tbl_assigned t3
WHERE t1.TraineeID=t3.TraineeID or t2.InstructorID
GROUP by t1.traineeid, t1.attnDate

最佳答案

您的OR 条件是错误的。它应该像这样WHERE (t1.TraineeID = t3.TraineeID OR t1.TraineeID = t2.InstructorID)查询应该是这样的:

SELECT t1.*
FROM tbl_attn_temp t1, tbl_instructor_info t2, tbl_assigned t3
WHERE (t1.TraineeID = t3.TraineeID OR t1.TraineeID = t2.InstructorID)
GROUP by t1.traineeid, t1.attnDate

关于mysql 比较两个表以查找匹配的记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33994975/

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