Learn sql and came the next question. How to implement a query to be showing a record that would have been identical in the two fields, or included in these ranges: data-time and data-time-end.
There is a table:
broadcasting
rows: id, data-time, data-time-end, nameprogramm, namechannel
some data are:
'1 ', '2012-01-09 13:00:00', '2012-01-09 13:30:00 ','News', 'Channel1'
'2 ', '2012-01-09 13:00:00', '2012-01-09 13:30:00 ','News', 'Channel2'
'3 ', '2012-01-09 13:05:00', '2012-01-09 13:35:00 ','News', 'Channel3'
'4 ', '2012-01-09 13:10:00', '2012-01-09 13:15:00 ','News', 'Channel4'
'5 ', '2012-01-09 11:00:00', '2012-01-09 12:00:00 ','News', 'Channel5'
'6 ', '2012-01-09 16:00:00', '2012-01-09 18:00:00 ','News', 'Channel6'
need to query brought:
date-time date-time-end channel
for those records that are in the range of date-time and date-time-end.
I think you need to select the maximum and minimum time. Then see if other records are in this range. But something is when it turns out, I will implement it. Thank you!
———————Add
Let me explain by the example of television programs.
We have the channels and transmission.
At what time news from the different channels are transmitted at one time? How many news channels broadcast at the same time? (The start time news is not necessarily the same).
results:
I want the result was as follows:
data-time data-time-end namechannel
2012-01-09 13:00:00 | 2012-01-09 13:30:00 | Channel1
2012-01-09 13:05:00 | 2012-01-09 13:35:00 | Channel3
2012-01-09 13:10:00 | 2012-01-09 13:15:00 | Channel4
To select records where the whole of the date range is between the specified start and end date, try:
To select records where any part of the date range is between the specified start and end date, try:
EDIT: To select records where any part of their date range overlaps any part of any other record’s date range for the same program, try: