Tag Info

New answers tagged


Suppose your date range is 2014-12-08 to 2014-12-11 This would be the Query you need SELECT B.*,A.quantity FROM ( SELECT AA.id,SUM(BB.quantity) quantity FROM ( SELECT id FROM orders WHERE date >= '2014-12-08' AND date <= '2014-12-11' ) AA INNER JOIN orderdetails BB ON AA.id = BB.order_id GROUP BY AA.id ) A ...


This should work, takes maximum use of your date index and minimizes possible join anomalies: SELECT (SELECT SUM(orders.amount) FROM orders WHERE orders.date >= [BEGIN DATE] and orders.date < [END DATE) amount, (SELECT SUM(od.quantitiy) FROM ordersdetails od INNER JOIN orders o ON od.id = o.id ...


If your table is InnoDB format, then try pt-online-schema-change (from Percona Toolkit), for example: pt-online-schema-change --charset utf8 \ --alter 'ADD COLUMN baz INT UNSIGNED' \ --execute -h db-test -u username -p password D=foo,t=bar

Top 50 recent answers are included