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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T11:53:46+00:00 2026-05-16T11:53:46+00:00

this post is a long one sorry for that but the problem is complex

  • 0

this post is a long one sorry for that but the problem is complex too.

Using mysql and php,
I can solve my problem with 3 sql requests, but not in 1, nor in 2.

So that’s why I post here :
does any of you know a way to do it in less than 3 strokes ?

(sorry for my english)

First let me explain the context :
it’s about theme park !

So there is the theme park owner,
and he owns a theme park with different zones, and each zone contains games.
Each game can be setup with different settings, according to a game manager (the human responsible for the game).

Here is what the interesting part of the schema looks like
there are 5 tables

themeparkzone
–name (varchar)

themeparkzone_has_game_with_manager
–themeparkzone_id (pk)
–game_id (pk)
–manager_id (fk)
–game_settings (text)

themeparkzone_has_game
–themeparkzone_id (pk)
–game_id (pk)
–game_settings (text)

game
–name (varchar)

manager
–name (varchar)

Two tables may need more explanations :

themeparkzone_has_game_with_manager and themeparkzone_has_game.

themeparkzone_has_game may hold the default settings for the games, if the themepark owner
wrote them.

Then themeparkzone_has_game_with_manager holds the game settings that the game_manager has (or has not) setup,
and those settings should override the default settings from the themeparkzone_has_game table when set up.

Because the themepark owner wants his themepark to be very attractive, he plans to change the settings every day,
and here is the convention that he and his team will have to deal with :

to decide which game settings will apply,

we have the following vars are given at startup :
– the manager_id : for example 22.
– the themeparkzone ids for today, for example 12,13,14

So the final goal is :
for the given manager_id, and for the given themeparkzone_ids,
find out the name and settings of the games,

given that :
if a setting is set in the themeparkzone_has_game_with_manager it will apply
else
if a setting is set in the themeparkzone_has_game it will apply
else
there is no game.

That’s the problem I have,
and because I could’nt do it within 1 request,
I spent a first request to loop the themeparkzone_ids,
so that the problem now is to find the game name and settings for a given manager_id and a given themeparkzone_id.

At this point, I can do it in two requests, but I wondered if one can do it in one.

My requests are :

SELECT g.name,w.game_settings
FROM game g
INNER JOIN themeparkzone_has_game_with_manager w on w.game_id=g.id
WHERE w.manager_id=22
AND w.themeparkzone_id in(12,13,14)

and

SELECT g.name,h.game_settings
FROM game g
INNER JOIN themeparkzone_has_game h on h.game_id=g.id
WHERE h.themeparkzone_id in(12,13,14)

Foreach of them, I put the resulting array in a php array and then mix them
according to the conventions.

So I was wondering if there was one way to solve the conditions in a mysql request
instead of doing it with php.

A request that would do something like this :
foreach (themeparkzone_id and manager_id)
if exists a matching setting in themeparkzone_has_game_with_manager
takeit,
else
if exists a matching setting in themeparkzone_has_game
takeit,
else
takenothing.

Hope someone understood what I tried to explain.

  • 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-16T11:53:48+00:00Added an answer on May 16, 2026 at 11:53 am

    Considering your database layout, I think it might be better to change some things.

    I would put themeparkzone_has_game_with_manager and themeparkzone_has_game_with_manager in one single table. Then I would create a new table games_managers that establishes a connection of which managers can manage which games.

    Then I think, it should be possible to do it with fewer requests.

    Note that you have to work out the details for yourself, i.e. you might specify a flag for each game if it needs to have a manager or not, etc.

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

Sidebar

Ask A Question

Stats

  • Questions 500k
  • Answers 500k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Are you asking how to convert it to a JSON… May 16, 2026 at 2:00 pm
  • Editorial Team
    Editorial Team added an answer In your onContextItemSelected callback, you can use this code to… May 16, 2026 at 2:00 pm
  • Editorial Team
    Editorial Team added an answer Apparently, Net::HTTP.get_response has passed Net::HTTPFound instance as http parameter into… May 16, 2026 at 2:00 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Sorry if this is a bit long winded but I thought better to post
Sorry for the long post that follows. I know that it is not a
I've got this 1 minute long movie that I want to compile into an
Using PHP / MySQL all encoded up as UTF, we have recently had to
It's taking me way to long to make this simple form. Almost there but
Sorry, i had to put the same post again due to still no solution
Recently, I made a post about the developers I'm working with not using try
Been banging my head against the wall on this one all day and am
As background, I gave an answer to this post a little while ago: Return
I'm using Sharepoint's Copy.asmx webservice to upload legacy files and their metadata. The target

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.