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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T16:44:39+00:00 2026-06-05T16:44:39+00:00

I have a table that acts as a dropbox for files that get automatically

  • 0

I have a table that acts as a dropbox for files that get automatically queued.

I order the priority of files based on two things, the date and time, and if it has been verified or not.

Here is my query:

$dropcount = mysql_query("SELECT COUNT(*) FROM queue WHERE status=2 OR status=3 
OR status=4 ORDER BY authorised DESC, timestamp DESC;");

What I need to do is count how many rows are ahead of the users current file because this will count every row, including the files behind the current users as well.

Thank you.

My table looks like this:

http://tabbidesign.com/table.png

The way this works is if a file is added its added to the queue. However if that file is authorised, it take priority over non verified files which means it needs to be counted even though it was added after some of the non verified flies.

The status column states if the file is:
-Being processed

-Queueing in the dropbox

-Cancelled by the user

-Cancelled by the admin

EDIT:
Ok @curtisdf’s answer would work if I did the following:

$countauth =
SELECT COUNT(*)
FROM queue
WHERE (status=2 OR status=3 OR status=4)
AND authorised=1
AND timestamp < $timestamp

$countnorm =
SELECT COUNT(*)
FROM queue
WHERE (status=2 OR status=3 OR status=4)
AND authorised=0
AND timestamp < $timestamp

$actualcount = $countnorm + $countauth;

How could I merge this into one query, or is this not possible?

THE SOLOUTION

SELECT COUNT(*)FROM queue WHERE (status=2 OR status=3 OR status=4)AND 
timestamp < $timestamp OR authorised=1

Found by @curtisdf.

  • 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-06-05T16:44:40+00:00Added an answer on June 5, 2026 at 4:44 pm

    Assuming your idqueue column is the primary key and it’s auto-incremented, what about using it to filter out later ID’s? Something like:

    SELECT COUNT(*) 
    FROM queue 
    WHERE status=2 OR status=3 OR status=4 
    AND idqueue < $currentFileId
    ORDER BY authorised DESC, timestamp DESC
    

    EDIT: It’s a little difficult to know how to answer because your table has so many columns and it’s not clear what you’re using all of them for. What does the status column mean, for example, in contrast to the authorized column? But anyway, since your ORDER BY doesn’t matter for this query, and since you’re looking for authorised files that came in prior to a given file, how about this:

    SELECT COUNT(*)
    FROM queue
    WHERE (status=2 OR status=3 OR status=4)
    AND authorised=1
    AND timestamp < $timestamp
    

    EDIT 2: Okay, now I see what you’re after. 🙂 If you just removed the “AND authorised=X” parts, I believe you could do it in one query. This assumes your authorised column only would have values of 0 or 1. But if it has more than that, then you could do it by wrapping the WHERE ... AND ... parts of each query in their own parentheses, like this:

    SELECT COUNT(*)
    FROM queue
    WHERE (
        (status=2 OR status=3 OR status=4)
        AND authorised=1
        AND timestamp < $timestamp
    ) OR (
        (status=2 OR status=3 OR status=4)
        AND authorised=0
        AND timestamp < $timestamp
    )
    

    This could be simplified even further:

    SELECT COUNT(*)
    FROM queue
    WHERE (status=2 OR status=3 OR status=4)
    AND timestamp < $timestamp
    AND (authorised=1 OR authorised=0)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have table that contain date and time field. id|date|time ========= 1|01/01/2001|10:45 2|01/02/2002|11:45 3|01/03/2003|12:45
I have a table that has three different date columns, so I set each
Ok this is the scenario... I have a table in Oracle that acts like
I've got a MySQL table that acts like a nested set in order to
I have a subview that acts as a container view in a table header.
I have a model that acts as a join table called CELEBRATIONS. CELBERATION has_and_belongs_to_many
I have table that I insert data with following query (from c# code): INSERT
I have a table that stores user information. The table has a userid (identity)
I have a table that has an AUTO_INCREMENT field. Currently, it is also a
I have a table that's created like this: CREATE TABLE bin_test (id INTEGER PRIMARY

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.