1
I have a code that could be of a natural person OR legal, and I have a table for each one (one for PF and another for PJ).
I would like to find this user in one of the two tables and return your information.
Bounce that he (user) will only be present in one of the two...
I’m doing it this way at the moment:
select *
user.ID as UserID
,conta.Email as Email
,pf.Nome as NomeUser
,pf.ID as IDUser
from Users user
inner join PFContas pfconta on pfconta.PFID = user.PFID
inner join PF pf on pf.ID = pfconta.PFID
inner join Contas conta on conta.Id = pfcc.ContaID
where
conta.ID = '579'
But this only applies to PF, as it would cause the same query to search in the table of PJ, if it did not find in this?
You’re a little confused. What comes to be pfcc? Can it exist as PF and PJ or just as one of the two? Evaluated if UNION does not meet you?
– anonimo