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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:49:56+00:00 2026-05-25T06:49:56+00:00

I’m learning PHP and Zend Framework. The following PHP function is supposed to fill

  • 0

I’m learning PHP and Zend Framework. The following PHP function is supposed to fill a temporary table using “INSERT INTO … SELECT” style query. However, when I SELECT * from the newly appended table, I see that most but not all of the new records have been duplicated once. I have deleted the contents of the table each time I run this scripts. Anyone know why there would be duplicates?

public function fillTableByOfficeName($officeName) {
    if ($officeName != '') {
        $officePhrase = "b.oof_name ='" . $officeName . "' AND ";
    } else {
        $officePhrase = '';
    }

    $whereAddenda = $officePhrase .
            "a.fil_bool_will_file_online = false AND " .
            "a.fil_bool_confirmed = false AND " .
            "a.fil_bool_duplicate = false AND " .
            "a.fil_bool_not_found = false AND " .
            "(a.fil_res_id_fk NOT IN (4,7,10) OR a.fil_res_id_fk IS NULL) AND " .
            "a.fil_will_recorder_rec_id IS NULL AND " .
            "d.tag_description NOT IN (
                'Already a trust client',
                'Not received from local office',
                'Southtrust client (already centralized)')";
            //"a.fil_date_of_transfer_to_will_recorder IS NULL";

    $sql = "INSERT INTO adds(fil_id,REC_ID,FIRST_NAME,LAST_NAME,MIDDLE_INITIAL,SSN," .
          "MAILING_ADDRESS_1,MAILING_ADDRESS_2,CITY,STATE,ZIP_CODE,PHONE_NUMBER,BIRTH_DATE," .
          "ORIGINATION_OFFICE,FILE_LOCATION,WILL_DATE,LAST_CODICIL_DATE,TRUST_DATE,REV_TRUST,POA_DATE) " .
          "SELECT a.fil_id_pk, " .
                "a.fil_will_recorder_rec_id, " .
                "a.fil_first_name, " .
                "a.fil_last_name, " .
                "a.fil_middle_name, " .
                "a.fil_ssn, " .
                "a.fil_mailing_address_1, " .
                "a.fil_mailing_address_2, " .
                "a.fil_city_address, " .
                "a.fil_state_address, " .
                "a.fil_zip_code_fk, " .
                "a.fil_phone_number, " .
                "a.fil_date_of_birth, " .
                "b.oof_name, " .
                "a.fil_box_id_fk, " .
                "a.fil_date_of_will, " .
                "a.fil_date_of_last_codicil, " .
                "a.fil_date_of_trust, " .
                "a.fil_notes, " .
                "a.fil_date_of_poa " .
          "FROM files a, origination_offices b, nn_files_tags c, tags d " .
          "WHERE " .
                "a.fil_oof_id_fk = b.oof_id_pk AND " .
                "a.fil_id_pk = c.fil_id_fk AND " .
                "d.tag_id_pk = c.tag_id_fk AND " .
                 $whereAddenda;
    $this->getAdapter()->query($sql);
    return $this;
}
  • 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-25T06:49:57+00:00Added an answer on May 25, 2026 at 6:49 am

    You are using C for a many to many relationship. For example, if you have invoices between companies and customers and you select from join of them, you will get as many rows as you have invoices. From that, if you only select the company name and costumer name, you will have many duplicates because the same pair has produced many invoices.

    This is the same issue you have here.

    As asc99c said, you could use an inner select to make your WHERE clause without joining on that relationship or you could use the DISTINCT key word (which effectively is a group by on everything in your SELECT clause). I would think the INNER SELECT solution more efficient (yet I could be totally wrong about that), but the DISTINCT way is 8 key press away…

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

Sidebar

Related Questions

I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I'm making a simple page using Google Maps API 3. My first. One marker
We are using XSLT to translate a RIXML file to XML. Our RIXML contains

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.