• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Two Joins to Single Table

Explorer ,
May 15, 2006 May 15, 2006

Copy link to clipboard

Copied

I need to be able to join two fields in table a with a single field in table b. I have chapterid and regionid in table a. I need to get the name of the region and the name of the chapter from the query based on the id values in table a. The problem is the structure of table b has regionid, regionname, ischapter fields instead of having a separate table for chapters. So I need to figure out a way to join chapterid in table a with regionid in table b AND regionid in table a with regionid in table b at the same time since I need it for each record. I have tried a bunch of things without success. Any ideas?

TIA
Heather
TOPICS
Advanced techniques

Views

204

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
May 15, 2006 May 15, 2006

Copy link to clipboard

Copied

LATEST
Assuming ischapter indicates if the record is a chapter or not

Select *
From tablea a, tableb b
Where a.regionid = b.regionid
or (b.regionid = a.chapterid and b.ischapter = true)

Ken

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation