Hi guys, I am having some trouble with a few SQL queries, I thought somebody may be able to tell me what is wrong...
This first one is supposed to pick out a user id if the user has a globally enabled photo, memo and is an active user, it also makes sure that users who have already been selected (and then inserted in to another table are not picked.
$usersql = "SELECT user.id FROM user, memory, photo, fordisplay
WHERE user.status=$activeuserflag AND
(memory.userid=user.id AND memory.status=$globalflag) AND
(photo.userid=user.id AND photo.status=$globalflag) AND
(user.id <> fordisplay.user) GROUP BY id LIMIT 1";
The problem is that it still picks users who have already been picked previously and inserted in to the fordisplay table. The (user.id <> fordisplay.user) was supposed to stop this from happening I though? This has been driving me crazy today.
The second problem Im having is a problem of logic. I have poll tables, I hold the datetime I want the poll to start, and the datetime I want the poll to finish. Now, how can I display any gaps in the poll schedules? E.g.say I have 4 polls with the following attributes:
- Start: 12:00:00 01-04-2004 End: 12:00:00 10-04-2004
- Start: 00:00:00 05-04-2004 End: 12:00:00 11-04-2004
- Start: 14:00:00 11-04-2004 End: 12:00:00 12-04-2004
- Start: 12:00:00 12-04-2004 End: 12:00:00 13-04-2004
So who would I display that there is a gap in the scheduling between polls 2 and 3? I don't think I can do this with mySQL I would have to load ALL data and work it out with PHP form what I can see? Correct? Any ideas?
Thanks,