_OwNeD.YoU_ Posted April 5, 2010 Share Posted April 5, 2010 Hi guys, i have these two querys selecting different dates from a table what would be the best way to get the difference like WHERE `MONTH` >= '". $data_lastfs . "' AND '" . $data_lastfsend . "' >= `MONTH` one query gets the current year and the other query gets last year. im lost :-( Link to comment https://forums.phpfreaks.com/topic/197673-combining-queries/ Share on other sites More sharing options...
ignace Posted April 5, 2010 Share Posted April 5, 2010 What do you want to accomplish and what is lastfs & lastfsend Link to comment https://forums.phpfreaks.com/topic/197673-combining-queries/#findComment-1037389 Share on other sites More sharing options...
taquitosensei Posted April 5, 2010 Share Posted April 5, 2010 probably a union $sql=" select yourfields from yourtable where `MONTH` >='".$data_lastfs."' UNION select yourfields from yourtables where MONTH < '".$data_lastfsend."'"; o r an or would probably work in this case $sql=" select yourfields from yourtable where `MONTH` >='".$data_lastfs."' or `MONTH` < '".$lastfsend."'"; Link to comment https://forums.phpfreaks.com/topic/197673-combining-queries/#findComment-1037396 Share on other sites More sharing options...
_OwNeD.YoU_ Posted April 6, 2010 Author Share Posted April 6, 2010 SELECT SUM(data.INVOICED) AS lfinvoice FROM `data` WHERE `MONTH` >= '2010-12-01' AND '2010-01-01' >= `MONTH` SELECT SUM(data.INVOICED) AS linvoice FROM `data` WHERE `MONTH` >= '2009-12-01' AND '2009-01-01' >= `MONTH` like combing these to get the difference of the two or have them in difference columns rather than 1 combined which was what was happening with "Union" Link to comment https://forums.phpfreaks.com/topic/197673-combining-queries/#findComment-1037525 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.