What would be the best way to combine these two SQL statements into one? I tried to use the union, but it seems Iām not going anywhere.
select id as id from likes where type=1; select sum(votes) as votes from likes where parent=id;
Here is the likes table:
id type parent country votes 1 1 0 US 0 2 2 1 US 6
This is the result that I am trying to achieve:
id | votes --------------- 1 | 9
source share