Home > OS >  SQL Join/Summarize/Fill empty columns - within one table
SQL Join/Summarize/Fill empty columns - within one table

Time:08-17

I think I need a join statement but all the join information I find is for 2 tables.

I have data like this:

enter image description here

And the rows refer to each other like this:

enter image description here

I would like to combine the rows, and end up with this:

enter image description here

I tried it with left join and inner join.

CodePudding user response:

You can self join tables if you use Aliases to identify them.

select t1.ID1, t1.ID2, t2.Genre, t1.Title 
from myTable t1
join myTable t2 on t1.ID2 = t2.ID1
  • Related