Where: RFC Emisor its an unique number that identifies every customer or company, eg. GARG87652TG9
So two customers or company can’t have the same RFC.
Razn Social: its the name of the Customer or company.
But many times customers they misspell his name, for example:
Razon Social RFC Emisor
PEREZ&SON’S Landscaping Co. Ltd --------- GARG87652TG9
PEREZ&SON’S Landscaping Co. Ltd --------- GARG87652TG9
PEREZ&SON’S Landscaping, Co. Ltd --------- GARG87652TG9
PEREZ&SON’S Landscaping, Co. L. t. d --------- GARG87652TG9
PEREZ&SON’S Landscaping, Co. LTD St. Infinite Loop --------- GARG87652TG9
In this database are a lot of customers with Name(Razon Social), and RFC Emisor.
But I only want to DISTINCT one customer using mySQL.
I mean I only want to make DISTINCT of RFC Emisor and choose only one name(RAZON SOCIAL) from the listed one.
I’m using this, but not does that I want:
“SELECT DISTINCT REPLACE((CONCAT(Emisor_Razon_Social,Emisor_RFC)), Emisor_RFC, ‘’) AS cc FROM Facturas_Recibidas”
[quote=262216:@Loannis Kolliageorgas]Why you don’t use the primary id?
Every record have primary key as id.[/quote]
But its a very very large list of customers
I can’t convert to unique the “RFC” cuz its a list of customers and items sold to us.
But I use this list to only get a list of customers
The users shouldn’t be asked to enter both the Razon Social and the RFC Emisor. Your app should ask for one and fill out the other automatically. You’re giving your users too big a chance to mess things up.
Absolutely correct.
If they have data entry screens, give them a list of names, let them choose one, and use the unique ID that is related to it.
Only if the name is missing is there a case to allow them to enter a new name, at which time a new RFC Emisor is required.
Use Dave’s multiple spellings code to identify RFC Emisor values that have two or more descriptions. Delete all but one of the rows.
Since RFC Emisor is supposed to be a unique identifier for a customer, arguably the table is not correctly defined, because it allows duplicates, making the ‘unique’ ID anything but.
You should set the database to not allow a new row with an existing ID, which means it will never happen again.