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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T01:20:34+00:00 2026-05-16T01:20:34+00:00

using mysql and php, I have two tables, I’m french so the table names

  • 0

using mysql and php,

I have two tables, I’m french so the table names may sound weird,
but I would like to keep them as originals to avoid errors when testing…

“arborescence” (it means categories)
“arborescence_domaine” (it means the subdomains for the categories)

The aim of this system is to be able to have great control
on the subdomains that depends on two things : the category and the zipcode.
Just to explain you before I dive into the problem,
for the same category, let’s say “car”,
for the zipcode 37000 the subdomain will be “supercars”
but for the zipcode 93000 the subdomain for the same category will be for example “the93supercars”

That’s why the “arborescence_domaine” contains the following fields :
id – arborescence_id – DEP – domaine – statut

where “DEP” is the zipcode and “domaine” the subdomain and “statut” is a bool
that decides if the subdomain is activated or not.

Now, the fun part begins …

What I would like to do is do it within 1 single sql query if possible.
(otherwise, I know thousands of php methods to achieve the same goal).

What I want now is get all the subdomains from a given array of category
and a given zipcode.
If the subdomain is not set, it doesn’t exist in the “arborescence_domaine” table.

But I want to have a result like this one :

cat_id domaine DEP
3 vehicule-occasion 37
14 immobilier 37
20 www NULL
26 services-divers 37
28 www NULL
37 www NULL
43 www NULL
3467 www NULL

That means that if the subdomain is not set, it may returns the default ‘www’ value.

Now without the zipcode I learned how to do it a faw hours ago :

This is a working request (the one that displayed the above array)
SELECT a.id as cat_id, IFNULL(d.domaine, ‘www’) as domaine, d.DEP
FROM arborescence a
LEFT JOIN arborescence_domaine d on d.arborescence_id=a.id
WHERE a.id in(3,14,20,26,28,37,3467,43);

But now with the zipcode I don’t get the expected result :

The following request :

SELECT a.id as cat_id, IFNULL(d.domaine, ‘www’) as domaine, d.DEP
FROM arborescence a
LEFT JOIN arborescence_domaine d on d.arborescence_id=a.id
WHERE a.id in(3,14,20,26,28,37,3467,43) AND d.DEP=’37’;

Give the following result :

cat_id domaine DEP
3 vehicule-occasion 37
14 immobilier 37
26 services-divers 37

Well, the “in database not existing subdomains” have gone away.

Now the question is :
Is it possible to have a result like the first result shown,
but using a zipcode filtering ?

(I thought I got it, but then a new problem occurred… as always…)

  • 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-16T01:20:35+00:00Added an answer on May 16, 2026 at 1:20 am

    The d.DEP should be in your ON clause:

    SELECT a.id as cat_id, IFNULL(d.domaine, 'www') as domaine, d.DEP
    FROM arborescence a
    LEFT JOIN arborescence_domaine d 
        ON d.arborescence_id=a.id AND d.DEP='37'AND d.status
    WHERE a.id in(3,14,20,26,28,37,3467,43);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

using php and mysql I have two tables, a users table and a profiles
I am using MySQL and PHP for a project I am working. I have
I have been using the mysql api in PHP, and am now converting to
Using PHP and MySQL, I have a forum system I'm trying to build. What
I have two tables (groups and parties) in a many to many relationship using
Been using PHP/MySQL for a little while now, and I'm wondering if there are
I'm building a wepage in php using MySQL as my database. Which way is
I am developing a PHP/MySQL application using vertrigoserver. I need to enter the German
I'm planning to make a very simple program using php and mySQL. The main
I am part of a team creating a web application using PHP and MySQL.

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.