I need advice of MySQL genius.
Table1 'objects':
ID (int,key,autoincrement) | hash(text) | name(text)
Table2 'logs':
ID (int,key,autoincrement) | hash(text) | type(int) | time(text) | sum(int)
Table1 'objects' links with Table2 'logs' by column 'hash'. That column contains MD5 values.
I need to get data with type=1 or type=2 in such way for every object:
Name | sum all rows for this name and type=1 | sum all rows for this name and type=2
Tried queries like this
SELECT name, SUM(sum) as tsum
FROM objects RIGHT JOIN logs using(hash)
WHERE (type='1' OR type='2')
GROUP BY type
But it forms data in format
Name | sum all rows for this name and type=1
Name | sum all rows for this name and type=2