Reputation: 259
Having this problem, I don `t know how to pull data from multiple tables. I tried to use INNER JOIN and UNION. Here is what I came so far:
select `name_ganre` from `teleprogram`.`ganres`
where `idganre`=any(select `idganre` from `teleprogram`.`ganre-transfer`
where `idtransfer`=any(select `idtransfer` from `teleprogram`.`broadcasting`));
select `name_channel` from `teleprogram`.`channel`
where `idchannel`= any(select `idchannel` from `teleprogram`.`broadcasting`);
I need to bring in one column name of the channel. And another name for the genre.
broadcasting
rows: idtransfer, idchannel
transfer
rows: idtransfer, name_transfer
ganre-transfer
rows: idganre, idtransfer
ganre
rows: idganre, name_ganre
channels
rows: idchannel, name_channel
I'm trying to get the data through broadcasting. May be simplified? After the query: name_channel, name_ganre
Thank you!
Upvotes: 1
Views: 79
Reputation: 66757
The query that you need is this:
select c.name_channel, g.name_ganre
from channels c
inner join broadcasting b on b.idchannel = c.idchannel
inner join ganre-transfer gt on gt.idtransfer = b.idtransfer
inner join ganre g on g.idganre = gt.idganre
You can see how INNER JOIN
works HERE!
Upvotes: 1