I have a MySQL Table, and a table where I do the next Query: Select Diferent Customer_Name in a Table where Customer_ID=CED130828MJ8.
The goal of that query is that only get a List on Customer_Name and Customer_ID.
Sometimes certains Customer_ID lacks of Customer_Name, (yep, I know about Unique KEY, but, thats not the ISSUE). So, cuz of this I do a CONCAT, IF Customer_Name is Empty, then Customer_Name = Customer_ID
Obiously ID_USER will change. Thats the Query that I do:
SELECT DISTINCT(
IF(Dealer_Name<>'',
CONCAT(Dealer_Name, '*',Dealer_ID),
CONCAT(Dealer_ID, '*',Dealer_ID)
)
) AS cc FROM received_invoices
WHERE Customer_ID='CED130828MJ8'
GROUP BY (cc)
ORDER BY cc ASC";
And thats how It looks the result of that QUERY:
"BEST BUY LTD CO*BTB052YU96"
And Almost works, I mean almost, because It only choose one Customer_ID of the table, but If a Customer_ID has two ore more records, it Will print, two records.
Let me show you:
"GERARDO GARCIA RIVERA*GARG870805726"
"GERARDO GARSIA RIBERA*GARG870805726"
"JERARDO GARZIA RIVERA*GARG870805726"
"JUAN ANTONIO MUÑOZ*MUGJ540314TV4"
"GUAN ANTONIO MUNIOZ*MUGJ540314TV4"
"JUAN ANTOÑO MUÑIOS*MUGJ540314TV4"
"JUAN HANTOIO MUÑOC*MUGJ540314TV4"
BUT THAT I really Want instead of that is only Get 1 Record per Customer_ID, like:
"GERARDO GARCIA RIVERA*GARG870805726"
"JUAN ANTONIO MUÑOZ*MUGJ540314TV4"
What Do I missing?, what did you suggest?
Thanks in Advance