to return the only distinct email,
SELECT DISTINCT b.cadastro_email FROM WMAIL_CADASTROS_GRUPOS a
INNER JOIN WMAIL_CADASTROS b ON a.cadastro_id = b.cadastro_id
INNER JOIN WMAIL_GRUPOS c ON a.grupo_id = c.grupo_id
WHERE
a.cadastro_id = ISNULL(@cadastro_id,a.cadastro_id) and
a.grupo_id = ISNULL(@grupo_id,a.grupo_id) AND
b.cliente_id = ISNULL(@cliente_id , b.cliente_id) AND
((b.cadastro_email like '%'+@nome+'%') OR (b.cadastro_nome like '%'+@nome+'%'))
But, i think you may wish to retrieve the other columns also, but i need a clarfication regarding that one. because you said that for one email, there are different groups, you wants to retrieve which group along with email,?
post whats your current output now and whats the output you required.
Liberan:
i think union always give distinct results. so no need to apply distinct clause or not in clause. just that query
select email from table1 union
select email from table2 union
select email from table3
just check this point. i just did some sample test.