Page 1 of 1

update query in mysql "from various date condition"

Posted: Fri Aug 31, 2007 5:44 am
by avmohankumar
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Dear Friends,

  I have a write a query, add the value from A field using group by based on values in A1.
                                and add the value from B field using group by based on values in B1.
                                and add the value from C field using group by based on values in C1.
                                and add the value from D field using group by based on values in D1.

   here A, B, C, D are the some amount fields. and A1, B1, C1, D1 are the date fields. Please suggest me to implement this query.

I have written three query,

Code: Select all

if($row['A'] != NULL)
{
$query = select SUM(A) as Q  from maza where A1= 2007-05-06 group by A1;
$flag =1;// check if flag is 1 display
}
if($row['B'] != NULL)
{
$query = select SUM(B) as w  from maza where B1= 2007-05-06 group by B1;
$flag =2;
}
if($row['C'] != NULL)
{
$query = select SUM(C) as E  from maza where C1= 2007-05-06 group by C1
$flag =3;
}
if($row['D'] != NULL)
{
$query = select SUM(D) as F  from maza where D1= 2007-05-06 group by D1;
$flag =4;
}

Regards,
maza.


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]