开发者

Please explain me the below query

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.

  1. What are you trying to do?
  2. What is the underlying data structure?
  3. How are your tables configured?

This considered:

  1. What is the content of $noticeeventsday
  2. Are you asking how to handle the returned results of the query? Or how the SQL actually functions/operates on your DB?
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜