This topic is locked

Registros duplicados cuando se lista

1/29/2021 8:22:11 AM
PHPRunner General questions
F
francoantonacci author

Saludos tengo un problema de duplicación de registros en el listado, en la base de datos no sucede eso, pero cuando ejecuto el sistema en la lista me aparecen los registros duplicados y si trato de borrar uno se borran los dos, gracias

Sergey Kornilov admin 1/29/2021

Do you use a JOIN SQL query? Results may multiply when you use such a SQL Query.

F
francoantonacci author 1/29/2021



Do you use a JOIN SQL query? Results may multiply when you use such a SQL Query.


Greetings, if I use it, I am including two tables, in the first one are the data of the person and the second his address. Here is the line inside the SQL:
SELECT

tbcomercio.idcomercio,

tbcomercio.idinmueble,

tbcomercio.idorgjur,

tbcomercio.idcondicom,

tbcomercio.idcontrib,

tbcomercio.nestcomercio,

tbcomercio.cnumpatcom,

tbcomercio.crazsoccom,

tbcomercio.ctipperson,

tbcomercio.nrifcom,

tbcomercio.nsufrifcom,

tbcomercio.ffecini,

tbcomercio.detramcom,

tbcomercio.cnumregcom,

tbcomercio.ctomoregcom,

tbcomercio.ffecregcom,

tbcomercio.clugregcom,

tbcomercio.rcapsuscom,

tbcomercio.rcappag,

tbcomercio.nnumempcom,

tbcomercio.nnumobrcom,

tbcomercio.ffecregsis,

tbcomercio.cnumexpfiscom,

tbcomercio.ntipexocom,

tbcomercio.rdeucomercio,

tbcomercio.cnomusuario,

tbcomercio.parcon,

tbcomercio.rcappag1,

tbcomercio.cobscom,

tbcomercio.ntipopropiedad,

tbdireccion.cdireccion,

tbcomercio.idrubro,

tbcomercio.tipocomercio

FROM tbcomercio

INNER JOIN tbdireccion ON tbcomercio.idcomercio = tbdireccion.idpropiedad

Sergey Kornilov admin 1/30/2021

If you have users that have multiple addresses then data will be duplicated. This is how JOIN SQL queries work.

F
francoantonacci author 1/31/2021



If you have users that have multiple addresses then data will be duplicated. This is how JOIN SQL queries work.



Thank you for your time, indeed you are right, could you help me choose only the first address I get, or better yet, eliminate duplicate addresses from the table of addresses.

Sergey Kornilov admin 2/2/2021

If you have duplicate addresses in your addresses table you need to clean your data removing duplicates in the database itself. This is the best option, why would you want to have duplicates?