I have 3 table:
table "f" (26000 record)
+------------------+------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------------+------------------+------+-----+---------+-------+
| idFascicolo | int(11) | NO | PRI | | |
| oggetto | varchar | NO |index| | |
+------------------+------------------+------+-----+---------+-------+
table "r" (22000 record)
+------------------+------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------------+------------------+------+-----+---------+-------+
| idRichiedente | int(11) | NO | PRI | | |
| name | varchar | NO |index| | |
+------------------+------------------+------+-----+---------+-------+
table "fr" (32000 record)
+------------------+------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------------+------------------+------+-----+---------+-------+
| id | int(11) | NO | PRI | | |
| idFascicolo | int(11) | NO |index| | FK |
| idRichiedente | int(11) | NO |index| | FK |
+------------------+------------------+------+-----+---------+-------+
This is my SELECT:
SELECT
f.idFascicolo,
f.oggetto,
r.richiedente
FROM fr
JOIN f ON (f.idFascicolo=fr.idFascicolo)
JOIN r ON (r.idRichiedente=fr.idRichiedente)
WHERE r.name LIKE 'string%'
How can I remove the duplicate in the result (i.e. "Rossi Mario" and "Rossi Marco" can be two r.name for the f.idFascicolo ), without using GROUP BY ?
How can I remove the duplicate using WHERE clause ?!
in this post I was suggested not to use GROUP BY, but I don't know how to do it ! Thank You a lot!
data expample:
"r" data
+---------------+------------------------
| idRichiedente | name |
+---------------+-----------------------+
| 1 | Rossi Mario |
+---------------+-----------------------+
| 2 | Rossi Marco |
+---------------+-----------------------+
"f" data
+---------------+-----------------------+
| idFascicolo | oggetto |
+---------------+-----------------------+
| 1 | oggetto1 |
+---------------+-----------------------+
| 2 | oggetto2..o |
+---------------+-----------------------+
"fr" data
+---------------+-----------------------+-----------------+
| id | idFascicolo | idRichiedente |
+---------------+-----------------------+-----------------+
| 1 | 1 | 1 |
+---------------+-----------------------+-----------------+
| 2 | 1 | 2 |
+---------------+-----------------------+-----------------+