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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:48:30+00:00 2026-06-13T13:48:30+00:00

I searching for many times now on a complex MySQL query. It’s an achievement

  • 0

I searching for many times now on a complex MySQL query.

It’s an achievement system.

Structure of tables is simple and form is symmetric.

The first table (achievements_base) contains the achievements reference : each achievement have :
– an ID (id of the row, auto-increment & unique),
– a code_id (reference of the achievement),
– a rank_id (sub-category of achievement’s code_id),
– and the achievement name (display purposes).

The second table (achievements_user) contains the achievements obtained by the users : each achievement unlocked have :
– an ID (if of the row, auto-increment & unique),
– the code_id (reference of the achievement),
– a rank_id (sub-category of achievement’s code_id),
– and the user id.

The tables syntax is :

achievements_base
id - code_id - rank_id - name
1 - 1 - 1 - foo
2 - 1 - 2 - bar
3 - 1 - 3 - foobar
4 - 1 - 4 - foofoo
5 - 2 - 1 - barbar

achievements_user
id - code_id - rank_id - user_id
1 - 1 - 1 - 1
2 - 1 - 2 - 1
3 - 2 - 1 - 1

I want to display achievements that user don’t have (GROUP BY code_id)

In the table exemple above, for example, expected result is, for the user_id 1 :
3 - 1 - 3 - foobar

But I don’t see how to do that ! I’ve already tried multiples queries.

Sorry for my English, I’m French !

Thanks !

edit, example of one of queries that I’ve tried :

SELECT AB.name
FROM achievements_base AB
RIGHT JOIN achievements_users AU 
ON AU.code_id = AB.code_id AND AU.rank_id = AB.rank_id
WHERE (SELECT COUNT(*) FROM achievements_users AU WHERE AU.user_id = 1) = 0
GROUP BY AB.code_id
ORDER BY AB.code_id ASC
  • 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-13T13:48:32+00:00Added an answer on June 13, 2026 at 1:48 pm

    How about the following?

    SELECT code_id
    FROM achievements_base
    WHERE code_id NOT IN
    ( 
       SELECT code_id
       FROM achievements_user
       WHERE user_id = 1
    )
    GROUP BY code_id
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I think this question has been asked many a times but I've been searching
First off hi all, and thanks for the many times searching here has helped
I'm attempting to learn prepared statements right now in PHP/MYSQL because of many suggestions
I need one string to be checked and modified many times (searching and replacing
After one week searching and converting many algorithm from other language into php to
This problem was asked many times, but none of solutions doesnt help me. I
Many times just find the right article and reading it on StackOverflow helped me
I have now coded up various graph search (A*, DFS, BFS, etc..) algorithms many
I'm sure this has been asked many times but I couldn't find the answer
Excel buffs: There are many results showing up when searching for comparisons between two

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.