I have Mysql query to be used in a php script. I just开发者_如何学运维 need to know how is it processing and producing output..
$sql = "SELECT events_id, events_name, control_id, (TO_DAYS(events_when) - TO_DAYS(NOW())) dayto "
."FROM events "
."WHERE events_active = 1 AND events_start = 1 AND "
." (TO_DAYS(events_when) - TO_DAYS(NOW())) IN $noticeeventsday ";
Select the event id, event name, control id and the number of days to the event (substract from the event date the acctual date converted to number of days)
SELECT events_id, events_name, control_id, (TO_DAYS(events_when) - TO_DAYS(NOW())) dayto
From the table events
FROM events
When the event is active (events_active =1), event start is one (i don't know the semantics of the fields.. sorry) and the number of days left to the event are included in the list of valid number of days ($noticeeventsday sould be a list like (1,2,3) so if the event is in the next one, two or three days it will be returned by the query.)
WHERE events_active = 1 AND events_start = 1 AND (TO_DAYS(events_when) - TO_DAYS(NOW())) IN $noticeeventsday
HTH!
It is hard to explain the query as it relates to you/your project/code without understanding the context, and whether you are experiencing a trouble with the SQL which you wish resolved.
- What are you trying to do?
- What is the underlying data structure?
- How are your tables configured?
This considered:
- What is the content of
$noticeeventsday
- Are you asking how to handle the returned results of the query? Or how the SQL actually functions/operates on your DB?
精彩评论