I know this has been asked before, but I'm having difficulty in grasping it. I rarely use raw SQL.
I have three tables - Session, GroupName and GroupSessionFeedback.
I'm joining Session to GroupFeedback on idUser
and I'm joining GroupName to Session on idGroup column.
Here's my SQL code:
SELECT s.idSession,
g.name,
s.Assistant,
s.idGroup,
s.start,
s.end,
f.value
FROM rempad.Session s
INNER JOIN rempad.GroupSessionFeedback f
ON s.idUser = f.idUser
INNER JOIN rempad.GroupName g
ON s.idGroup = g.idGroup
WHERE s.start BETWEEN '2013-04-28' AND '2013-05-28'
AND s.idUser = 22
OR s.idUser = 23
OR s.idUser = 24
OR s.idUser = 26
OR s.idUser = 27
OR s.idUser = 28
OR s.idUser = 42;
I want it to bring back unique idSessions but it is matching it multiple times because of the Joins and I really haven't an idea what other approach to take. I could make separate calls to the database - but I'm really trying to avoid hammering the database as it's pretty slow response as it is.
Any ideas?
Thanks in advance