Sorry asking such a newbie question but I've been trying to understand this SQL query and add a thing and i can't make it happen.
Here is the query:
select
p.id, p.nick, p.creation_date
from
tb_player p
left outer join
tb_invoice i on (i.player_id = p.id), tb_player_last_login tpl
where
p.creation_date < now() - '12 months'::interval
and tpl.last_login_date < now() - '12 months'::interval
and tpl.player_id = p.id
and p.id > 9999
and (p.email = 'EDITE-SEU-EMAIL' or p.email = 'configure-seu-email')
and i.id is null
limit 15000;
So I'm selecting a group of people from this tb_player and I have another table called tb_email_list and I need to say somewhere to include the players of tb_player that have the same email of tb_email_list that are valid.
tb_player has nick and email camp
tb_email_list player_id, email, is_valid
I tried to put some joins but nothing I do seems to work...
A little help please?
My friend helped me and it goes like
select p.id, p.nick, p.creation_date
from tb_player_last_login tpl, tb_player p
left outer join tb_invoice i on (i.player_id = p.id)
left join tb_email_list e on e.player_id = p.id
where p.creation_date < now() - '12 months'::interval
and tpl.last_login_date < now() - '12 months'::interval
and tpl.player_id = p.id
and p.id > 9999
and (p.email = 'EDITE-SEU-EMAIL' or p.email = 'configure-seu-email' or e.is_valid = -1)
and i.id is null
limit 15000