I have multiple tables, I can list their rows to my website.
What I want is where last column has same value, I want to add up rows values and list as one line.
What I have:
Hioss
AUR
Top
1
1
0
Shen
Hioss
AUR
Top
1
1
0
Shen
Kanani
AUR
Jungle
1
1
0
Reksai
I don't want to get data like this. If last column has same values (Shen) I want to sum int values and show as one line at my website.
What I want to do:
Hioss
AUR
Top
2
2
0
Shen
Kanani
AUR
Jungle
1
1
0
Reksai
My mysql query:
mysql_query("SELECT * FROM table1 UNION SELECT * FROM table2");
How can I do it? What should I do?
UNIONquery in an outer query that groups/sums them, ie.SELECT col1, col2, col3, SUM(col4), SUM(col5), col6 FROM (SELECT * FROM table1 UNION SELECT * FROM table2) a GROUP BY col6(note thecol1-col6are just examples, as you don't give explicit column names)