Originariamente inviato da max103
devo fare un DISTINT dopo una query con DISTINCT
questa è la query attuale:
Codice PHP:
SELECT DISTINCT `a1` , `a2` , `a3`
FROM `ricette`
WHERE `id` = '7'
OR id = '6'
OR id = '4'
LIMIT 0 , 30
il problema sta nel fatto che potrei avere sia in a1 che in a2 lo stesso valore...
risultato:
pippo, pippo, pluto
come posso fare il distinct anche tra a1 - a2 - a3?
Beh...facile (vabbeh, passamela
)
codice:
SELECT DISTINCT `a1` , `a2` , `a3`
FROM `ricette`
WHERE (`id` = '7'
OR id = '6'
OR id = '4') AND
`a1` != `a2` AND
`a1` != `a3` AND
`a2` != `a3`
LIMIT 0 , 30
Non è efficentissima, ma funziona 