* Ciubotariu Catalin > Your solution work only with a table of clients, I don't have one. I > have only 6 tables with clients and amounts and I need to join them. > Should I have to make a table with clients? It's realy necessary?
Please reply to the list, others may have similar problems. :) Yes, you need a client table, unless you use a newer version of mysql (4.1 or later) and can use UNION and sub-selects. Then you could perhaps do something like this: SELECT C,sum(A1),sum(A2),sum(A3),sum(A4),sum(A5),sum(A6) FROM ( SELECT C,A1,0.0 A2,0.0 A3,0.0 A4,0.0 A5,0.0 A6 FROM T1 UNION SELECT C,0.0 A1,A2,0.0 A3,0.0 A4,0.0 A5,0.0 A6 FROM T2 UNION SELECT C,0.0 A1,0.0 A2,A3,0.0 A4,0.0 A5,0.0 A6 FROM T3 UNION SELECT C,0.0 A1,0.0 A2,0.0 A3,A4,0.0 A5,0.0 A6 FROM T4 UNION SELECT C,0.0 A1,0.0 A2,0.0 A3,0.0 A4,A5,0.0 A6 FROM T5 UNION SELECT C,0.0 A1,0.0 A2,0.0 A3,0.0 A4,0.0 A5,A6 FROM T6) GROUP BY C This is not tested, I don't have 4.1 myself. I don't know if this combination of UNION and sub-select will work. -- Roger -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]