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 7073805
In Process

The Archive Base Latest Questions

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

Hello I have a problem with fetching required rows from MySQL table correctly within

  • 0

Hello I have a problem with fetching required rows from MySQL table correctly within date interval.

My table has had such structure originally (yes with unixtimestamps not mysql dates):

    id    name    departures                   depmin         depmax 
-------------------------------------------------------------------------
    1      a      1327608000                 1327608000     1327608000

    2      b   1321646400,1322856000,        1321646400     1337976000
               1325880000,1327694400,
               1329508800,1330718400,
               1331928000,1332532800,
               1333137600,1333742400,
               1334347200,1334952000,
               1336161600,1336766400,
               1337371200,1337976000

    3      c   1315166400,1316894400,        1315166400    1327780800
               1317758400,1318968000,
               1319918400,1320004800,
               1320091200,1320177600,
               1321387200,1324152000,
               1325448000,1325534400,
               1325620800,1327780800
------------------------------------------------------------------------

My task is to get all 3 rows with departure between 1327536001 and 1327881601 but if I query like so:

SELECT * FROM exampletable WHERE depmin >= 1327536001 AND depmax <= 1327881601

I only get the first row (with id 1 and name a). So I’m totally confused how to get all three rows between this example interval?

Please advise how to construct my where query or how to reformat the table.

  • 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:58:26+00:00Added an answer on May 28, 2026 at 5:58 am

    If I understand your question correctly, you want to get all the id‘s where any timestamps from column departures fall within specific interval.

    Unfortunally, there is no simple way to achieve that. You’ll have to either write an extensive stored procedure/function (involving parsing string from departures column, putting results in array variable or temporary table, comparing them to your borders etc.) or you’ll have to redesign your database heavily.

    Personally, I’d suggest to move data from departures column into separate table, one departure time per row, like this:

       id            departure
    ------------------------------
        1        1327608000
        2        1321646400
        2        1322856000
    ...
    

    Then you will be able to satisfy your original requirements with query like

    SELECT * FROM exampletable WHERE id IN (SELECT id FROM departures WHERE departure >= 1327536001 AND departure <= 1327881601)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello I have a problem with compiling a ghostscript from ports in openbsd 4.7.
Hello I have a problem to retrieve a value from a method. I'm using
Hello I have this problem: I have MySQL Database with collation latin1_bin . In
hello i have a problem in getting picture from the url contained in the
Hello I have following Problem: Within an uninstall-process I load a JAR (jdbc-driver). URL
Hello I have problem to put together animations of two separate objects to second
Hello I am a Java web app developer I have a problem, I would
Problem Hello all! I have this code which takes my jpg image loops through
Hello I have a table on which I have denied SELECT privs to a
Hello I have a problem with this http://jsfiddle.net/E7dGA/1/ When the script starts and you

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.