0
I have three tables! One of them is a relation table!
Are they:
Relationship Table between Person and Treatment:
I would like that when passing the person’s ID, the query returns the NAMES of the selected treatments. Example: ID 8, he would return Reiki and Astrology; ID 9, he would return Reiki, Astrology and Coaching Personal Development!
What’s happening in my consultation:
I already tried to make the consultation putting Distinct
, but it’s not working! It’s like he’s returning two results(what I hope are two results same) only that’s coming all other treatments too.
My snippet of code:
Select * FROM tratamento INNER JOIN pessoa_tratamento_r ON 8 = pessoa_tratamento_r.ID_PESSOA
Thanks in advance for the help! And please, if you want to put links or other indications for study, do this! If there are other ways to do this research as well, please say!
select t.nome from tratamento t inner join pessoa_tratamento pt on pt.id_tratamento = t.id_tratamento and pt.id_pessoa = 8
– Rovann Linhalis