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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:23:22+00:00 2026-05-23T03:23:22+00:00

Hi have the following tables: table districts: id DD text —|—-|—– 1 | 01

  • 0

Hi have the following tables:

table districts:

id   DD   text   
---|----|-----
1  | 01 | texas     
2  | 02 | ny     
5  | 03 | washington   

table councils:

id   DD   CC   text
---|----|----|-----
1  | 01 | 01 | text1 
2  | 02 | 01 | text2
5  | 02 | 02 | text3
3  | 02 | 03 | text4
4  | 03 | 01 | text5
5  | 03 | 02 | text6
6  | 01 | 02 | text7

table person:

id   name    DD   CC
---|-------|----|----
1  | john  | 02 | 03 
2  | mike  | 03 | 02
3  | julia | 01 | 02

I want to make a query so I get the following result:

result:

 name     District    Council
-------|------------|-------
 john  | ny         | text4 
 mike  | washington | text6
 julia | texas      | text7

So far I have the following query:

select p.name,d.text as district,c.text as council
    from  person p 
        inner join districts d on p.DD=d.DD
        inner join councils c on p.DD=c.DD and p.CC=c.CC
where 1;

I think that the logic should be correct but somehow I’m getting an error… Can anyone help understand this or point me in the right direction??

If I do this it returns results but not the expected of course:

select p.name,d.text as district,c.text as council
    from  person p 
        inner join districts d on p.DD=d.DD
        inner join councils c on p.CC=c.id
where 1;

Thanks

EDIT: It was a collation problem… My advice if you find this is to not use query browser ’cause errors are not very verbose… There might be an option in it but I dont’t know!

Thank you all

  • 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-23T03:23:22+00:00Added an answer on May 23, 2026 at 3:23 am

    I had no idea of your schema, but here’s what I did (and it works fine!)

    CREATE TABLE `districts` (
        `id` INT(10) unsigned NOT NULL,
        `DD` CHAR(20) NOT NULL,
        `text` CHAR(100) NOT NULL,
        PRIMARY KEY (`id`)
    ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
    
    CREATE TABLE `councils` (
        `id` INT(10) unsigned NOT NULL,
        `DD` CHAR(20) NOT NULL,
        `CC` CHAR(20) NOT NULL,
        `text` CHAR(100) NOT NULL,
        PRIMARY KEY (`id`)
    ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
    
    CREATE TABLE `person` (
        `id` INT(10) unsigned NOT NULL,
        `DD` CHAR(20) NOT NULL,
        `CC` CHAR(20) NOT NULL,
        `name` CHAR(100) NOT NULL,
        PRIMARY KEY (`id`)
    ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
    
    INSERT INTO districts (`id`, `DD`, `text`) VALUES ('1','01','texas');   
    INSERT INTO districts (`id`, `DD`, `text`) VALUES ('2','02','ny');   
    INSERT INTO districts (`id`, `DD`, `text`) VALUES ('5','03','washington');
    
    INSERT INTO councils (`id`, `DD`, `CC`, `text`) VALUES ('1','01','01','text1');
    INSERT INTO councils (`id`, `DD`, `CC`, `text`) VALUES ('2','02','01','text2');
    INSERT INTO councils (`id`, `DD`, `CC`, `text`) VALUES ('3','02','03','text4');
    INSERT INTO councils (`id`, `DD`, `CC`, `text`) VALUES ('4','03','01','text5');
    INSERT INTO councils (`id`, `DD`, `CC`, `text`) VALUES ('5','03','02','text6');
    INSERT INTO councils (`id`, `DD`, `CC`, `text`) VALUES ('6','01','02','text7');
    
    INSERT INTO person (`id`, `name`, `DD`, `CC`) VALUES ('1','john','02','03');
    INSERT INTO person (`id`, `name`, `DD`, `CC`) VALUES ('2','mike','03','02');
    INSERT INTO person (`id`, `name`, `DD`, `CC`) VALUES ('3','julia','01','02');
    
    SELECT p.name, d.text AS district, c.text AS council
    FROM person p
    INNER JOIN districts d ON p.DD = d.DD
    INNER JOIN councils c ON p.DD = c.DD
    AND p.CC = c.CC
    WHERE 1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following tables CREATE TABLE `files` ( `fileid` int(11) NOT NULL AUTO_INCREMENT,
I have the following tables: CREATE TABLE title ( booktitle VARCHAR( 60 ), title_id
I have the following tables: create table TableA ( Id int primary key identity,
I have the following two tables, affiliates and referrers. affiliates Table id loginid 3
I have two tables with the following (simplified) structures: table "Factors" which holds data
I have the following tables: --table sportactivity-- sport_activity_id, home_team_fk, away_team_fk, competition_id_fk, date, time (tuple
I have the following tables: CREATE TABLE IF NOT EXISTS `Person_Categories` ( `PrsCatID` int(11)
I have the following tables: CREATE TABLE `attendance_event_attendance` ( `id` int(11) NOT NULL AUTO_INCREMENT,
Let's say you have the following two tables: X Table X_ID Y_ID_F X_Value 1
I have following tables: CREATE TABLE IF NOT EXISTS stats ( date date NOT

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.