Cannot compare time periods. how can I solve this problem?

Source: Internet
Author: User
I cannot compare the time period. I have a question: I have a program for online TV playback ., I want him to display the program name of the current time period. The TV data table is contentid (miniint (8), auto-increment), description (text), streamurl (varchar) (It is mainly used to store streaming media and cannot compare time periods.
There is a problem:

I made a program for online video playback ., I want him to display the program name for the current time period

The TV playback data table is:

Contentid (miniint (8), auto-increment );
Description (text );
Streamurl (varchar) (mainly used to store streaming media addresses)
Player (varchar) (mainly stores the player to be loaded)

The data table of the TV Festival is

Programid (miniint (8), auto-increment)
Contentid () is the id associated with the video playback;
Description program introduction
Starttime () (start time)
Endtime () (end time)

However, you do not know how to associate the program so that the program can be played for a period of time.

Example:

What you are watching is that Beijing TV is currently playing: Discovery

For help.

------ Solution --------------------
What type is the starttime and endttime fields.
------ Solution --------------------
Select * from, playing table where. contentid = Playing Table. contentid and now () BETWEEN starttime and endtime
------ Solution --------------------
Your table does not reflect the day of the week. The day of the week is a property of the program. You must first create such a field. You can use multiple SQL statements.
Or you can find out all programs by time. Just remove it by using the program.
------ Solution --------------------
Explanations

Discussion

Reference:

Select * from, playing table where. contentid = Playing Table. contentid and now () BETWEEN starttime and endtime


This problem cannot be solved. Because my program may be periodic, for example, broadcast on Monday and Tuesday, and not broadcast at other times. The input time to the database is a fixed timestamp. If I skip to the next day, I can't compare it ......

------ Solution --------------------
The data stored in the table is a timestamp, and the current time can also be a timestamp. Can the two timestamps be compared?
------ Solution --------------------
Data is dead, and people are active.
You are not serving data, but data.

You have
Example:
What you are watching is that Beijing TV is currently playing: Discovery

Of course it is now.


In the code I #3, now should be CURRENT_TIME
Your starttime and endtime should also save the time value, such as 08:26:30 or 082630 instead of the timestamp.

------ Solution --------------------
Cross-day? On what day?
What broadcast and television programs have you ever seen?
All night cinema is also a place.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.