I have two tables like below;
table1
===========================
| table1_ID | table1_name |
===========================
| 1 | A |
| 2 | B |
===========================
table2
======================================
| table2_ID | table2_qty | table2_ID |
======================================
| 22 | 4 | A |
| 23 | 9 | A |
| 24 | 12 | B |
| 25 | 23 | B |
======================================
and the ouput should look like this:
================================
| table1_ID | name | total_qty |
================================
| 1 | A | 13 |
| 2 | B | 35 |
================================
"table2 ID , name & the total sum value of 'table2_qty' with the same ID from 'table1_ID'"
I tried this , but the results isn't like what I want.
SELECT table1.table1_ID, table1.table1_name,
SUM(table2.table2_qty) As total_qty
FROM table1, table2
GROUP BY table1.table1_ID, table1.table1_name;
How to get that results in SQL?
Thanks!