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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:58:29+00:00 2026-05-26T04:58:29+00:00

I am trying to match up data between two tables by using the same

  • 0

I am trying to match up data between two tables by using the same values from the main query in the sub-query. I am using 3 tables for this:

World – The area of the world that the player has been in
Player – The actual player
Objects destroyed – Just a stats table used to keep track of the player’s progress in the world

What I am trying to do is to create a query that displays the play and the world they were in and get a count of all the objects they have destoryed in that world. My query is currently like this:

select
    world_id,
    world_name,
    player_id
    count(select * from objects_destoryed where player_id = <insert player ID>) as Stats
from
    Worlds
    join Players using (player_id)
where
    player_id = <insert player ID>

What I am asking is if there is a better way rather then including the player ID twice to get the overall statistics. Also is there a way that I can expand this to run on multiple players that were in that world? Such as using a player_id in statement.

Thanks for any advice

  • 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-26T04:58:29+00:00Added an answer on May 26, 2026 at 4:58 am

    I have not used postgresql, but in other flavors of SQL, something like this would work:

    select
        world_id,
        world_name,
        player_id
        count(*) as Stats
    from
        Worlds
        join Players using (player_id)
        join objects_destroyed using (player_id)
    where
        player_id = <insert player ID>
    group by world_id, world_name, player_id
    

    The goal is for the select statement to return one row for each object destroyed by the player in the world, and then allow the group by clause to collapse the rows with the same world and player into a single row, with the number of rows consolidated into “Stats.”

    In order to make this return results for several players, you would just change your where clause so that it keys off of the world, rather than the player. Each player with a presence in that world would have his own row.

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

Sidebar

Related Questions

I'm trying to extract/match data from a string using regular expression but I don't
I am trying to match <input> of type hidden fields using this pattern: /<input
Trying to match this data, that is contained in one string: vsan 1 interfaces:
I am trying to match the text contents(character data) of an XML file with
I'm trying to match elements with a name that is 'container1$container2$chkChecked' , using a
I have two databases, on two separate SQL Servers (trying to consolidate both). This
I am trying to calculate difference(in seconds) between two date/times formatted as following: 2010-05-11
I am trying to make the transition from using call-template to using applay templates
I am trying to compare two byte arrays in memory and produce a data
I am trying to add a relationship between 2 tables, but i am getting

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.