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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:16:39+00:00 2026-05-30T00:16:39+00:00

I am trying to create a query which returns offers for all rows that

  • 0

I am trying to create a query which returns offers for all rows that belong to a club_id that are within a start_date & end_date, however the query should also return results for any that match the club_id AND the end_date is 0 – any ideas of how to do this?
My current query is below…

SELECT 
    * , 
    UNIX_TIMESTAMP( start_date ) AS start_dateStamp, 
    UNIX_TIMESTAMP( end_date ) AS end_dateStamp 
FROM 
    (`offers`) 
WHERE 
    UNIX_TIMESTAMP(  `start_date` ) <1329308797 
AND 
    UNIX_TIMESTAMP(  `end_date` ) >1329308797 
AND 
    `club_id` =23
  • 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-30T00:16:40+00:00Added an answer on May 30, 2026 at 12:16 am
    SELECT
      `offers`.* ,
      UNIX_TIMESTAMP( start_date ) AS start_dateStamp, 
      UNIX_TIMESTAMP( end_date ) AS end_dateStamp 
    FROM `offers`
      WHERE  `club_id` =23
      AND (
        (
          `start_date`<FROM_UNIXTIME(1329308797)
           AND `end_date`>FROM_UNIXTIME(1329308797)
        )
        OR `end_date`=FROM_UNIXTIME(0)
      )
    

    Please note, that I moved the convertion from unix-timestamp to MySQL-date from the field to the constant – this way it has to be converted only once, and not for all rows. Additionally this way an index can be used.

    Edit

    With “date zero” not being Unix-Zero but MySQL-Zeor the last line should be

    OR `end_date`='0000-00-00'
    

    additionally, if the data type of start_date and end_date is not DATETIME but DATE you need

    DATE(FROM_UNIXTIME(...))
    

    instead of

    FROM_UNIXTIME(...)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to write a SQL query that returns rows from a table
I'm using EF4.1 code first, I'm trying to to create a query which returns
I am trying to create a report in SSRS2000 that will query an ORACLE
I am trying to create Linq Expression that I can use to query child
An application of mine is trying to execute a count(*) query which returns after
I am trying to create a WCF Data Service that returns objects that look
I'm trying to create a query with the Criteria API from JPA 2.0, but
I'm trying to create a simple database table using the PHP MySQL query Create
I have 4 databases with similar schema's, and I'm trying to create a query
I'm trying to create a linq query based on some dynamic/optional arguments passed into

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.