I have this code:
$prikaz = mysql_query("select t.*
from (
SELECT mesta_email, mesta_meno, mesto
FROM mesta2014
UNION
SELECT mesta_email, mesta_meno, mesto
FROM mesta2015
)
t left join mesta3 t3 on t.mesta_email = t3.mesta_email
where t3.mesta_email is null
")
I need to not show the same emails in results, even though the other columns (mesta_meno
and mesto
) are different. So there could be two rows with different information except for mesta_email = in result there has to be only one result. Can you help me please with solving this?
If the values of mesta_meno
and mesto
do not matter, then do the following:
$prikaz = mysql_query("select t.mesta_email, min(t.mesta_meno) as mesta_meno, min(t.mesto) as mesto
from (
SELECT mesta_email, mesta_meno, mesto
FROM mesta2014
UNION
SELECT mesta_email, mesta_meno, mesto
FROM mesta2015
)
t left join mesta3 t3 on t.mesta_email = t3.mesta_email
where t3.mesta_email is null
group by t.mesta_email
")