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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T05:35:59+00:00 2026-06-05T05:35:59+00:00

I have two tables, one with monster names and their respective scores: CREATE TABLE

  • 0

I have two tables, one with monster names and their respective scores:

CREATE TABLE `mobscores` (
  `name` TINYTEXT NOT NULL ,
  `score` TINYINT NOT NULL
);

and one with the actual kills on my server:

CREATE TABLE `mobkills` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `name` tinytext NOT NULL,
  `mob` tinytext NOT NULL,
  `item` smallint(6) NOT NULL DEFAULT '0',
  `date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
);

Now i could do the brute-force way and read the first table into a hash (Using Perl here, but that shouldn’t matter for the question.), read in mobkills line for line after telling MySQL that i want the kills from one player starting at $whateverdate and then use the returning mob field on the hash to retrieve the score to add to the totals.
But i know that SQL is powerful so that i don’t need to do that myself.
So, the question is, how do i tell MySQL to exchange, or even count together, the mob name for the score from table mobscores?

Something like this (fantasy syntax incoming as i don’t know the real one):

SELECT score (AS score FROM mobscores WHERE name=mob) 
FROM mobkills 
WHERE name= 'McMiner' AND date >= SomeQueryDateToStartFrom;

I don’t know if MySQL could even add up score for me so that i don’t need to do that by foot in the Perl script, but that would be optional.
Thanks in advance. 🙂

EDIT:
Yay, thanks to rkosegis hint i got this. 😀

SELECT name, sum( (SELECT score FROM mobscores WHERE mobscores.name = mobkills.mob)) 
as score 
FROM mobkills group by name order by score desc
  • 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-05T05:36:00+00:00Added an answer on June 5, 2026 at 5:36 am

    Try:

    SELECT (SELECT sum(score) FROM mobscores WHERE mobscores.name = mobkills.name GROUP BY name) as Score
    FROM mobkills 
    WHERE name= 'McMiner' AND date >= SomeQueryDateToStartFrom;
    

    Alternatively, you could use an inner join…

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

Sidebar

Related Questions

I have two tables one with ID and NAME table 1 ID | NAME
I have two tables : one table it matchs and the other is teams.
I have two tables connected with one to many relationship. Parent Table is a
I have two tables and their only difference is one column is missing from
I have two tables. One user table and one table in which results are
I have two tables: one table (okay, it's a view), vComputer, lists many computers
I have two tables one to many: Table1 ID Name 1 Abe 2 David
I have two tables one named Person , which contains columns ID and Name
Ok, so I have two tables in MySQL. One table holds customer information, the
I have two tables one Employee and mailing Subscriptions Employee looks like this: Name

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.