Jump to content

Combining queries?


_OwNeD.YoU_

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.