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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:52:24+00:00 2026-06-03T02:52:24+00:00

Directly under this small intro here you’ll see the layout of the database tables

  • 0

Directly under this small intro here you’ll see the layout of the database tables that I’m working with and then you’ll see the details of my question. Please provide as much guidance as possible. I am still learning PHP and SQL and I really do appreciate your help as I get the hang of this.

Table One (‘bue’) —
chp_cd
rgn_no
bgu_cd
work_state

Table Two (‘chapterassociation’) —
chp_cd
rgn_no
bgu_cd
work_state

Database Type: PostgreSQL

I’m trying to do the following with these two tables, and I think it’s a JOIN that I have to do but I’m not all that familiar with it and I’m trying to learn. I’ve created a query thus far to select a set of data from these tables so that the query isn’t run on the entire database. Now with the data selected, I’m trying to do the following…

First and foremost, ‘work_state’ of table one (‘bue’) should be checked against ‘work_state’ of table two (‘chapterassociation’). Once a match is found, ‘bgu_cd’ of table one (‘bue’) should be matched against ‘bgu_cd’ of table two (‘chapterassociation’). When both matches are found, it will always point to a unique row within the second table (‘chapterassociation’). Using that unique row within the second table (‘chapterassociation’), the values of ‘rgn_no’ and ‘chp_cd’ should be UPDATED within the first table (‘bue’) to match the values within the second table (‘chapterassociation’).

I know this is probably asking a lot, but if someone could help me to construct a query to do this, it’d be wonderful! I really do want to learn, as I don’t wish to be ignorant to this forever. Though I’m not sure if I completely understand how the JOIN and comparison here would work.

If I’m correct, I’ll have to put this into seperate queries which will then be in PHP. So for example, it’ll probably be a few IF ELSE statements that end with the final result of the final query, which updates the values from table two to table one.

  • 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-03T02:52:25+00:00Added an answer on June 3, 2026 at 2:52 am

    A JOIN will do both level of matching for you…

      bue
    INNER JOIN
      chapterassociation
        ON  bue.work_state = chapterassociation.work_state
        AND bue.bgu_cd     = chapterassociation.bgu_cd
    

    The actual algorithm is determined by PostreSQL. It could be a merge, use hashes, etc, and depends on indexes and other statistics about the data. But you don’t need to worry about that directly, SQL abstracts that away for you.

    Then you just need a mechanism to write the data from one table to the other…

    UPDATE
      bue
    SET
      rgn_no = chapterassociation.rgn_no,
      chp_cd = chapterassociation.chp_cd
    FROM
      chapterassociation
    WHERE bue.work_state = chapterassociation.work_state
      AND bue.bgu_cd     = chapterassociation.bgu_cd
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a div directly under the body. My HTML looks like this: <body>
This question may not directly relate to programming. I have noticed that the technology
In this simple example, I have 5 GroupBox es, directly under a Grid .
I have this SQL query, and directly under it, another query based on the
Dictionaries and lists defined directly under the class definition act as static (e.g. this
I have this hierarchy, a tabcontainer(tcmain) under that a tabpanel(tpnlRaiseMRF) under that an asp
This question is directly related to this SO question I posed about 15 minutes
I have astring directly coming form the database and I am creating object of
For the downvote fairies.. I know that php is the wrong language for this...
My question is: How can I get elements directly under a specific parent element

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.