Sample Header Ad - 728x90

Detect with Left Join duplicates entries and return the first value, also return sum of duplicates entries

0 votes
1 answer
1035 views
¡Hi!, i have a case with two tables than can have a lot of matches entries and the time of fetching increases a lot. This tables can be Table A: Employees ------------------------- | Name | ID | Account | ------------------------- | Nicole | 01 | 12345 | | Alexis | 02 | 67890 | ------------------------- And Table B: BankAccounts -------------------------- | Name | ID | Account | -------------------------- | Nicole | 01 | 12345 | | Nicole | 01 | 67890 | //duplicates Accounts | Alexis | 02 | 67890 | //duplicates Accounts -------------------------- And i want to do this with a Left Join in a Table that can have more of 450,000 different entries Result Table C Column_A = ¿Exists the account number in other register? Column_B = if(NumberOfMatches > 1) //this means that the account be found in other user AND i want to get the first value of all posibles number of matches |Account exists in other user|Match in User.. ----------------------------------------------------------------------------- | Name | ID | Account | Column_A | NumberOfMatches | Column_B | BadID | --------------------------------------------------------------------|-------| | Nicole | 01 | 12345 | No | 1 | Nicole (OK) | null | | Alexis | 02 | 67890 | Yes | 2 | Nicole (BAD)| 01 | ----------------------------------------------------------------------------- Thanks and regards! Note: sorry for my english, im learning :p
Asked by user186910
Feb 20, 2020, 05:38 AM
Last activity: Aug 1, 2025, 04:06 AM