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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:03:42+00:00 2026-06-11T21:03:42+00:00

Ok i think i am going about this the wrong way possibly, but i

  • 0

Ok i think i am going about this the wrong way possibly, but i have tried so many different ideas and cannot seem to find the right way to do this, so hoped somebody might be able to nudge me in the right direction.

Basically i record the ip address of visitors as they visit my website, and then identify which of the ip addresses belong to businesses.

So table one has a long list of ip addresses of people who have visited my website and table two has a list of ip addresses i have identified.

Now what i am trying to do is find out how many of the IP addresses in Table 1 have been identified.

The code i have below matches and groups the ip addresses and shows me how many times the ip address in table 2 appears in table one.

However what i am trying to get is just one number and not a group of numbers, i have tried writing the query several ways but can only get it to work with a group

SELECT ip_stats.ip, COUNT(ip_stats.ip) 
FROM ip_stats 
LEFT JOIN main USING (ip)
GROUP BY ip_stats.ip

ip_stats is table one and has the long list of people visiting my website.
main is table two and contains the details of the IP addresses which have been identified.

both tables have their own primary key both are which are id.

Thanks

  • 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-11T21:03:43+00:00Added an answer on June 11, 2026 at 9:03 pm

    COUNT the ip on main table

    SELECT ip_stats.ip, COUNT(`main`.ip)
    FROM ip_stats 
    LEFT JOIN main USING (ip)
    GROUP BY ip_stats.ip 
    

    UPDATE 1

    ah ok, so you only want one value for all ip that are present on main table right? then you don’t need to use LEFT JOIN for this, instead use INNER JOIN

    SELECT COUNT(DISTINCT ip_stats.ip)
    FROM ip_stats 
         INNER JOIN main USING (ip) 
    

    DISTINCT was added so only unique values are being counted.

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

Sidebar

Related Questions

Hey, I think I'm going about this the wrong way, but have tried many
I think I'm going about this the wrong way. This is what I'm trying
Perhaps I'm going about this the wrong way, but I'm using HXT to read
Very likely I'm going about this in the wrong way entirely. I'm completely new
I'm probably going about this all wrong, but hey. I am rendering a large
I'm probably going about this the wrong way, please feel free to correct me.
I could be going about this the wrong way. I am trying to put
I think this is going to be one of those simple-when-you-see-it problems, but it
I think I'm going insane with this. I have a a piece of code
I think the answer to this is no going in, but I could use

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.