I have two tables, A and B, and I am trying to select rows from A based on a join query. I am getting some records from these tables, but there are some duplicate entries. How should I filter this query to avoid duplicate rows? For now, I'm doing it via Java code by putting these into a HashSet.
The keyword DISTINCT is used to eliminate duplicate rows from a query result:
SELECT DISTINCT ...
FROM A
JOIN B ON ...
However, you can sometimes (possibly even 'often', but not always) avoid the need for it if the tables are organized correctly and you are joining correctly.
To get more information, you are going to have to ask your question more clearly, with concrete examples.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With