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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:30:19+00:00 2026-05-20T09:30:19+00:00

I am querying the database to return a simple array. IE: SELECT * FROM

  • 0

I am querying the database to return a simple array.
IE: “SELECT * FROM contacts LIMIT 50”

But what i’m trying to figure out is, what if the user only has 10 contacts. I would like to show a response saying (10 of 10) contacts showing.

I know I could run 2 queries on the database,
a. SELECT * FROM contacts (and then count the results)
b. SELECT * FROM contacts (and then find the difference of A and B

But the problem lies when a user has 2,000 contacts which wouldn’t be uncommon. and then querying the database every time the user selects the “contacts” page.

So is there a simpler way to do this? or am I on the right track?

Any light would be appreciated.
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-20T09:30:20+00:00Added an answer on May 20, 2026 at 9:30 am

    Another approach

    select *,
         (select count(*) from table) as `found`,
         (select 10 - count(*) from table) as missing
    from table limit 10
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm querying a database like this: SELECT * from Log WHERE cookieId IN (select
I have an SQL server database that I am querying and I only want
I have a simple problem when querying the SQL Server 2005 database. I have
Question: I can get the SQL Server database language by querying: SELECT @@language And
This has got me all confused! I'm trying to return the max value from
I am querying database from my EJB Bean, which is DAO, my query look's
In my situation, I am querying a database for a specific return (in this
I am querying a database of latitude and longitude values and want to return
I am attempting to select column names from a SQL Server database with the
I am getting the data from sqlite database and trying to display it in

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.