我正在尝试从tbl_attn_temp
获取TraineeID
与tbl_assigned
TraineeID
或tbl_instructor_info
InstructorID
匹配的所有数据。但我将所有数据与tbl_assigned
TraineeID
匹配。 tbl_instructor_info
数据未显示或显示此查询,如下所示:
tbl_attn_temp
tbl_assigned
tbl_instructor_info
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
答案 0 :(得分:4)
您的OR
条件错误。它应该是这样的 WHERE(t1.TraineeID = t3.TraineeID或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
答案 1 :(得分:0)
尝试此查询
SELECT t1.traineeid, t1.attnDate
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
如果使用GROUP BY子句,则可以允许按列选择(在您的情况下为traineeid,attnDate),并允许在一列或多列上执行聚合函数。