Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7065889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:00:44+00:00 2026-05-28T05:00:44+00:00

Learn sql and came the next question. How to implement a query to be

  • 0

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
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T05:00:45+00:00Added an answer on May 28, 2026 at 5:00 am

    To select records where the whole of the date range is between the specified start and end date, try:

    select * from broadcasting 
    where `date-time` >= ? /* start of date range */
      and `date-time-end` <= ? /* end of date range */
    

    To select records where any part of the date range is between the specified start and end date, try:

    select * from broadcasting 
    where `date-time` <= ? /* end of date range */
      and `date-time-end` >= ? /* start of date range */
    

    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:

    select * from broadcasting b1
    where exists (select null
                  from broadcasting b2
                  where b1.nameprogramm = b2.nameprogramm and
                        b1.`date-time` <= b2.`date-time-end` and 
                        b2.`date-time` <= b1.`date-time-end` and
                        b1.id <> b2.id)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

From a previous question , I learn that Linq to SQL is not able
I'm trying to learn SQL and trying to write a SQL Query that does
Hey, a beginner's question here.... In order to learn PHP and SQl I have
I have been writing some queries about SQL Server in order to learn. I
I am trying to learn SQL query optimization using SQL Server 2005. However, I
I'm trying to learn LINQ to SQL and I'm able to query the database
I'm trying to learn SQL and for demonstration purposes I would like to create
I would like to learn SQL by creating and running queries. However, it does
From my experience I have learn that using an surrogate INT data type column
I am just beginning to learn SQL and have stumbled at the first hurdle,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.