I'am trying to get the sum of the two columns from different tables, even though I got great posts on ads is. Some of them This query amount of coulmns down somehow Incorrect total, Returns (materialprice column Coulmn)> mysql> TBL AS_Servicesets; + ---------- + ---------- + | Ticket_id | Rate | + ---------- + ---------- + | 11 | 250.00 | | 11 | 300.00 | | 11 | 400.00 | | 9 | 300.00 | | 9 | 300.00 | | 9 | 1500.00 | | 9 | 250.00 | + ---------- + ---------- + Total 2 350.00 mysql & gt; Tbl as_ticketmaterials; + ---------- + --------------- + | Ticket_id | Physical value. + ---------- + --------------- + | 11 | 100 | | 9 | 20 | | 9 | 50 | + ---------- + --------------- + 70.00 total is query ------- -------------- ////
Tuesday, 15 January 2013
mysql - Getting the sum of several columns from two tables result is not correct -
This is not the right way to get the desired result. Try instead: -
SELECT (SELECT SUM (`as_servicetickets``````````````) as` circcut 'as `as_servicetickets` where`s_ Servicizers' .`ticket_id` = 9), (SELECT Yoga (`as_ticketmaterials` .`materialprice`) as` sercnt` as `as_ticketmaterials` where` as_ticketmaterials` .`ticket_id` = 9);