-1

Using this question's answer. I'm trying to find duplicate records between two tables by the column names matrix_unique_id and Matrix_Unique_ID in each table and then display the full address. The Full address columns are formatted differently from each other in each table so I cannot use that as a comparison. I'm getting an "unknown column fort_property_res.matrix_unique_id" error but everything looks okay?

So two questions:

  1. Will this query find duplicates correctly?

  2. Why the unknown column error?

SQL query:

SELECT matrix_unique_id, full_address 
FROM fort_property_res
INNER JOIN (
    SELECT Matrix_Unique_ID, FullAddress 
    FROM sunshinemls_property_res
    GROUP BY FullAddress 
    HAVING count(fort_property_res.matrix_unique_id) > 1
) dup ON fort_property_res.matrix_unique = sunshinemls_property_res.Matrix_Unique_ID
Community
  • 1
  • 1
Rocco The Taco
  • 3,695
  • 13
  • 46
  • 79

1 Answers1

2

The solution you're trying to copy is a totally different case. You have two tables and (it looks like) a convenient matrix_unique_id to join on, so this is much easier:

SELECT fort.matrix_unique_id, fort.full_address AS fortAddress, sun.FullAddress AS sunAddress
FROM fort_property_res fort, sunshinemls_property_res sun
WHERE fort.matrix_unique_id = sun.Matrix_Unique_ID
Sourav
  • 17,065
  • 35
  • 101
  • 159
Digital Chris
  • 6,177
  • 1
  • 20
  • 29