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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:27:24+00:00 2026-05-24T03:27:24+00:00

i have a 3 Tables: 1 TableTraders trader_id|Domain| ——————— 1|google.com 2|yahoo.com 2 Table Counter_in

  • 0

i have a 3 Tables:

1 TableTraders
trader_id|Domain|
---------------------
1|google.com
2|yahoo.com

2 Table Counter_in

counter_time    counter_ip  counter_domain_id
    111111  222222  1
    111111  222224  2
    111111  222225  3
    111111  222232  2
    111111  222221  3
    111111  222223  4
    1111311     22223422    5



 3 Table Out Counter
counter_time    counter_ip  counter_domain_id
    111111  222222  1
    111111  222222  2
    111111  222222  3
    111111  222226  2
    111111  222221  3
    111111  222222  4
1309351485  2130708581  5
    1309351485  2130708581  4
    1309710116  2130706433  4
    1309351485  2130708581  1
1309710274  2130706433  1

Ok what i want todo is join the tables 1 , 2 , 3 and group them together, and count them.

trader_id|DOMAIN|IN|OUT
--------------------------
1|google.com|3|1
2|yahoo.com|1|2

I tried many things, but i get always wrong results. How do i join right the queries that i get results i want

*EDIT

The query attempted:

SELECT traders.trader_id, traders.domain, COUNT( counter_in.counter_domain_id ) AS today_in, COUNT( counter_out.counter_domain_id ) AS today_out
FROM traders
JOIN counter_in ON traders.trader_id = counter_in.counter_domain_id
JOIN counter_out ON traders.trader_id = counter_out.counter_domain_id
GROUP BY traders.trader_id, traders.domain
LIMIT 0 , 30

Results:

trader_id   domain  today_in    today_out
1   bing.com    3   3
2   google.com  4   4
3   yahoo.com   4   4
4   msn.com     3   3
5   yandex.com  1   1
  • 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-24T03:27:26+00:00Added an answer on May 24, 2026 at 3:27 am

    It appears the other answer may be giving you some sort of Cartesian result thus duplicating results. Take your traders and join to distinct sub-query counts from respective in / out tables.

    SELECT
          TT.trader_id,
          TT.Domain,
          TIN.InCount,
          TOUT.OutCount
       FROM 
          TableTraders TT
    
             LEFT Join ( select Trader_ID, count(*) as InCount
                       from TableIn
                       group by Trader_ID ) TIN
                on TT.Trader_ID = TIN.Trader_ID
    
             LEFT Join ( select Trader_ID, count(*) as InCount
                       from TableOut
                       group by Trader_ID ) TOUT
                on TT.Trader_ID = TOUT.Trader_ID
    

    If you want it by DISTINCT IP address per in/out, just change

    COUNT(*) 
    to
    COUNT( Distinct IP )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my database I have tables that define types for example Table: Publication Types
Hi i have tables like this : table entry : id | total_comments _____________________
I have tables: Teachers and Students. We have a SpecialProjects Table where Teachers and
I have tables item and store (it's a store management system). item table has
I have tables foo and bar: create table foo(a int, b varchar(10), primary key
I have tables & data like this: venues table contains : id +----+---------+ |
I have tables of data samples, with a timestamp and some data. Each table
I have tables named Events and Log. The Events table comprises of ID, Event
I have two tables, say Table A and Table B. I want to have
Say we have tables A, B, and C and then we want table Z

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.