Hi,
please, i have a problem when i try to add UNION to my query in Mysql:
error : MySQL said: #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'union (select StrYearr,StrDATE,0,3)
What I have tried:
code (Procedure):
<pre lang="SQL">
begin
DECLARE Mont INT default 1;
DECLARE StrDATE varchar(7) ;
DECLARE StrYearr varchar(7) ;
set StrYearr = StrYear ;
set StrDATE = CONCAT(Mont,'-',StrYearr);
drop temporary table if exists TableHelp;
create temporary table TableHelp
(
PeriodY year,
PeriodM varchar(10),
MtnSTaxes float,
TypeEntr int
);
while (Mont <=12) do
insert into TableHelp(PeriodY,PeriodM,MtnSTaxes,TypeEntr)
(
select (SecTabDatePaieY,SecTabDatePaieM,sum(SecTable.SumV_Prix),3)
from (select Date_Format(p.DatePaie,"%Y")as SecTabDatePaieY,Date_Format(p.DatePaie,"%m-%Y")as SecTabDatePaieM,(select sum(V_Prix) from lsthelpget_montsansfrais where V_configYesNon=1 and V_IdPaie= p.IdPaie and V_IdFAct=p.IdFact) as SumV_Prix from paiement p where PayePaie=1) as SecTable
where SecTable.SecTabDatePaieM=Date_Format(StrDATE,"%m-%Y") group by SecTable.SecTabDatePaieM asc UNION (select StrYearr,StrDATE,0,3)
);
set Mont= Mont+1 ;
END WHILE;
SELECT PeriodM,MtnSTaxes,TypeEntr from TableHelp;
end