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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:03:35+00:00 2026-06-04T18:03:35+00:00

I think this is simple question but google only gives me select and count

  • 0

I think this is simple question but google only gives me select and count results.

I’m wondering if it is possible to select from a table with a limit and count all the rows that would normally be affected by the query.

For example:

I got 100 rows in table cars and I select the first 20 I want the count how many cars there are in the cars table in one query.

Thanks in advance

  • 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-04T18:03:37+00:00Added an answer on June 4, 2026 at 6:03 pm

    If I understand your need (I understand it to be that you want the result of your limited query plus the number of rows in the full table), this can be done with a SELECT subquery, or with a JOIN against a subquery. Since you only expect one row back from the count query, you can use a cartesian join (with no ON clause). The count of all rows then appears as the same value for each column.

    SELECT
      cars.*,
      carcount.numcars
    FROM
      cars
      JOIN (SELECT COUNT(*) AS numcars FROM cars) carcount
    LIMIT 20
    

    Would produce a result like

    make     model     numcars
    ford     focus     100
    ford     model t   100
    ...
    ...
    20 rows, numcars always = 100
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Actually my question is simple. I think. But unfortunately, Google can't help me this
i think this is a simple question but I've searched around and can't seem
I think this is a simple question, but I can not find the answer
I think this is a simple question. How do I disable copy from a
I think this is a pretty simple question. How do you an apache rewrite
I think this should be a fairly simple question for anyone who knows PHP.
[see later answer for more] I think this is just a simple rails question,
This is a simple question I think. I am trying to search for the
I'm hoping this question has a very simple answer. I can think of ways
I am sure there is a very simple answer to this question, I think

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.