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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:07:15+00:00 2026-05-17T20:07:15+00:00

This query would get one row with the id and the number of ID

  • 0

This query would get one row with the id and the number of ID in the Messages.

SELECT id, count (id) FROM Messages

and I need that could get a list of id in the second field was the number

EDIT:

I do paged media.
To do this I need to know how many of these lines that would make the button “next” active or not active

I used C#

  • 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-17T20:07:15+00:00Added an answer on May 17, 2026 at 8:07 pm

    It sounds like you’re trying to get both the id of the first row number and the overall count of rows in a single row of data, so you don’t have to either do two queries or run a query returning a lot of rows just for the purpose of finding out how many rows it returns.

    Try something like this:

    SELECT MIN(id), COUNT(id) AS count
      FROM Messages
    

    or, if you want the first batch of data rows matching some criterio along with the count you could try something like this:

    SELECT detail.id, detail.message_text, detail.user, summary.count
      FROM (SELECT id, message_text, user
              FROM Messages
             WHERE user = 'user'
             ORDER BY id ASC) detail
      JOIN (SELECT COUNT(*) count
              FROM Messages
             WHERE user = 'user') summary
      LIMIT by 0,10
    

    If you put indexes on your user and id columns this query will be decently efficient. All the rows will have the same value for summary.count, which is the number you want to control your next-page button’s visibility.

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

Sidebar

Related Questions

I would like to get the number of rows that satisfies the condition. mysql_query(SELECT
How would I do in a SELECT query to reverse this path : z/y/x
I am having trouble writing a query to select one row per date, given
A have a code like this: $em = $this->getDoctrine()->getEntityManager(); $query = $em->createQuery(SELECT p FROM
I've been struggling with this one SQL query requirement today that I was wondering
How would I rewrite this query to be performant by executing the SQL function
I would like to turn this query to regular inline sql without using stored
By any chance you would be able to help optimize this query without me
I have a specific DB2 query, and I would like to execute this query
am trying to squeeze some performance out of this query, any help would be

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.