I'm working on a project and I need to get some data from database. First of all I have activities and they depend on a day of a planification. I want to award users who have done the activities the first week, for exemple.
In order to get the activities of the first week I'm doing this SQL:
SELECT activitat
FROM planning_activitats
WHERE (activitat <> 'CTS' AND activitat <> 'TRU' AND activitat <> 'Test')
AND dia >= 1 AND dia <= 7
This query is correct and I get all the activities in a correct way. Ok, now I want to know what users have done these activities and I do this SQL:
SELECT user
FROM activitats_completades
WHERE activitat = ALL ($sql)
AND user NOT IN (SELECT user FROM puntuacions_setmanals WHERE setmana = 1)
Where $sql is the first SQL. The second part of WHERE (AND user NOT IN...) is because I need to manage what users have been awarded and they can't be awarded another time.
I think the problem is in ALL operator because I'm doing the query and I'm getting 0 results. What I'm doing bad? I have checked database and data is correct and it should give me some user because I have users who have done all the activities.
Thanks for your help.
EDIT: Data samples -> User "user" have done activities "ACT1, ACT2, ACT3", "user2" have done "ACT1, ACT4" and this week activities are "ACT1, ACT4". In this case, "user2" should be the result.
= ALL (3, 5, 7). Did you meanWHERE activitat IN ($sql)?