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

  • Home
  • SEARCH
  • 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 768221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T18:08:53+00:00 2026-05-14T18:08:53+00:00

I thought I was doing the right thing but I keep getting the wrong

  • 0

I thought I was doing the right thing but I keep getting the wrong result. I am trying to simply find the id of the entry with the min time, but I am not getting that entry.

$qryuserscount1="SELECT id,min(entry_time) FROM scrusersonline WHERE topic_id='$topic_id'";
$userscount1=mysql_query($qryuserscount1);
while ($row2 = mysql_fetch_assoc($userscount1)) {
    echo $onlineuser= $row2['id'];
}

That is my query, and it does not work. This however does work which does not make sense to me
SELECT id FROM scrusersonline WHERE topic_id=’$topic_id’ ORDER by entry_time LIMIT 1, can anyone quickly point out what I am doing wrong?

  • 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-14T18:08:54+00:00Added an answer on May 14, 2026 at 6:08 pm
    SELECT id,min(entry_time) FROM scrusersonline WHERE topic_id='$topic_id'
    

    will return id and entry_time for every row matching topic_id, since there is no group-by clause from which the min(entry_time) could be selected. The SELECT clause only defines what columns are to be returned, it doesn’t restrict that selection by rows any – that’s what the WHERE clause is for.

    SELECT id FROM scrusersonline WHERE topic_id='$topic_id' ORDER BY entry_time LIMIT 1
    

    will return id (SELECT id) for only the first (LIMIT 1) matching topic_id (WHERE topic_id='$topic_id') when ordered by entry_time (which is the minimum).

    So, yes, SELECT id FROM scrusersonline WHERE topic_id='$topic_id' ORDER BY entry_time LIMIT 1 is what you’re looking for.

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

Sidebar

Related Questions

I thought I was doing the right thing here but I get several warnings
I thought doing a simple animation would be easy but is is taking hours
There are many examples on the internet of doing this type of thing. But
I don't know if I'm doing something wrong, but I'm 100% sure it's the
I just want to make sure I'm doing the right thing. I have a
i am doing a continuously select every 10seconds, so i thought i would do
Although I have my php validation doing this, thought I may as well pop
Another noob regex problem/question. I'm probably doing something silly so I thought I'd exploit
can anyone help, i have problem doing a sort, I thought i had it
Thought my range of search options would easily find this. I wish to combine

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.