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

The Archive Base Latest Questions

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

Apologies for the title, I am wanting to run a query like so: $query

  • 0

Apologies for the title, I am wanting to run a query like so:

$query = mysql_query("
  select * from taskdetail
  where userid = '" . $rec['id'] . "'
    and comp_status = '0'
    and duedate > '" . date("Y-m-d") . "'
  order by duedate,importantlevel ASC
  LIMIT " . $getnextrecord . " , $limit
");

and then run one like so

$query_noduedate = mysql_query("
  select * from taskdetail
  where userid = '" . $rec['id'] . "'
    and comp_status = '0'
    and duedate = '0000-00-00'
") or die(mysql_error());

I would like the results of the second query (tasks with no duedate) to appear below the first queries results, (almost as if it is the results of the first query).

The reason being is I have lots of extra functionailty that alters the number of tasks you see, so eg if the user had selects to see one result and click next it currently goes through each task, I simpy want to kind of append the second queries results at the end of the first instead of having two sets of results.

I could combine the queries together eg:

$query = mysql_query("
  select * from taskdetail
  where userid='" . $rec['id'] . "'
    and comp_status='0'
    and ( duedate > '" . date("Y-m-d") . "' or duedate = '0000-00-00' )
  order by duedate,importantlevel ASC
  LIMIT " . $getnextrecord . " , $limit");

However, the tasks with the duedate of 0000-00-00 will appear at the top.

Not sure of the best solution

Cheers

  • 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:57:41+00:00Added an answer on May 30, 2026 at 12:57 am

    There could be 2 ways:

    Query 1 – by modifying the ORDER BY

    $query = mysql_query("select *
        from taskdetail
        where userid='" . $rec['id'] . "'
        and comp_status='0'
        and  ( duedate > '" . date("Y-m-d") . "' or duedate = '0000-00-00' )
        order by (CASE
            WHEN duedate > '0000-00-00' THEN duedate
            ELSE '9999-99-99'
            END), importantlevel ASC
        LIMIT  " . $getnextrecord . " , $limit");
    

    Query 2 – adding another column ‘custom_date’ to the SELECT and using it for ORDER BY

    $query = mysql_query("select *, (CASE
            WHEN duedate > '0000-00-00' THEN duedate
            ELSE '9999-99-99'
            END) AS `custom_date`
        from taskdetail
        where userid='" . $rec['id'] . "'
        and comp_status='0'
        and  ( duedate > '" . date("Y-m-d") . "' or duedate = '0000-00-00' )
        order by `custom_date`, importantlevel ASC
        LIMIT  " . $getnextrecord . " , $limit");
    

    Hope it helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Apologies for the very broadly title question. Basically this follows on from my earlier
(Apologies for the title of this question - I wasn't overly sure how to
Apologies for the long winded title but looking for a solution to what might
My apologies for an inaccurate title, but I'm not sure what this is called
First off - apologies for the poor title, I have no idea how to
First of all, apologies for the subjective sounding title. This is intended as a
Apologies for the fuzzy title... My problem is this; I have a SQL Server
I understand that the title was very vague and my apologies. I am using
Not a very good title, so my apologies. For some reason, (I wasn't the
Firstly, apologies for the vague title, but I'm not sure exactly what I'm asking

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.