MySQL Forums
Forum List  »  Newbie

Re: SELECT mit NOT EXISTS
Posted by: Hans Huber
Date: May 20, 2020 09:44AM

Hi,

one more question.

I got my query now I want to have the name from the person Table and the Email vom the adress table. But there can be more than just on adress table. I tried to do it like this:

select
person_id, name, vorname, email
sum( if(detail_id=6 and status=1,1,0) ) as d1s1,
sum( if(detail_id=3 and status=0,1,0) ) as d2s0,
sum( if(detail_id=3,1,0) ) as d4
from detailzuordnung
LEFT JOIN person ON (detailzuordnung.person_id = person.id)
LEFT JOIN adressen ON (adressen.Person_id = adressen.Person_id)
group by person_id
having (d1s1>0 and d2s0>0) OR (d1s1>0 and d4=0)

but it is not workin it allways tells me that the person_id is ambigous
If I just use the first LEFT JOIN for person it is working.

Do you have any Idea what I can do?

Thank you

Options: ReplyQuote


Subject
Written By
Posted
May 13, 2020 08:53AM
May 13, 2020 06:01PM
May 13, 2020 07:13PM
May 14, 2020 05:57PM
May 19, 2020 10:11AM
Re: SELECT mit NOT EXISTS
May 20, 2020 09:44AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.