php - SQL INSERT from SELECT producing duplicate records -


I am learning PHP and Zend Framework. The following PHP function should fill a floating table by using the "INSERT INTO ... SELECT" style query. However, when I select * from the newly added table, I feel that most of the new records but not all has not been repeated once every time I run this script for the table Has the content removed? Anyone know how to duplicate?

  to fill public functions Office Ofisnam ($ officeName) {if ($ officeName! = '') {$ OfficePhrase = "b.oof_name = '". $ OfficeName "and"; } And {$ officePhrase = ''; } $ Where Addenda = $ officePhase "A.fil_bool_will_file_online = false" "A.fil_bool_confirmed = false" "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 taps and" "D.tag_description NOT IN ( 'already a trusted client," did not receive the local office' Sauthstrast client (already centralized) ') "; //"a.fil_date_of_transfer_to_will_recorder is the IS tap "; $ Sql ​​= "INSERT (file ID, REC_ID, FIRISHD, LASER, MIDILIDITAIL, SSN,". "" MAILING_ADDRESS_1, MAILING_ADDRESS_2, CITY, STATE, ZIP_CODE, PHONE_NUMBER, BIARTADE, "" ORIINGIFES, FILE_LOCATION, WILL_DATE, LAST_CODICIL_DATE, Trst_det, Rev_trst, Pioa_det) "." Select Akfil_id_pak, "." Akfil_vil_rikorder_res_id, "" Akfil_frst_nam, "" Akfil_last_nam, "" Akfil_midil_nam, "" Akfil_ssn, "" Akfil_meling_adres_l , "" 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, "" Bikoof_nam, "" A.fil_box_id_fk "" Akfil_det_ofa_vil, "" Akfil_det_ofa_last_kdaikil, "" Akfil_det_ofa_trst, "" Akfil_nots, "." A. fil_date_of_poa "said on" one "files, Utptti_ofijhs B, C Nn_files_tags, tag D". "." 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 () - & gt; Query ($ SQL); $ this return; }    

If you are using C to many relationship for many people. For example, if you have invoices between companies and customers, and you choose to join them, you will receive several rows in the form of invoices. That, if you choose only the company name and Costiar name, you'll have several duplicate because the same pair has produced several invoices.

This is the same problem you have here.

As Asc99c, you can use an internal selection to make your WHERE clause without being involved in the relationship, or you can use different key words (which is effectively your SELECT is a group on everything in the section). I think INNER SELECT solution is more efficient (even though I could be totally wrong about that), but different path 8 key press away ...

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -