From: admin
Date: May 3 2012 3:13am
Subject: Stored Procedure Problem.
List-Archive: http://lists.mysql.com/php/217
Message-Id: <09ee01cd28da$a84f6710$f8ee3530$@com>
MIME-Version: 1.0
Content-Type: multipart/alternative;
boundary="----=_NextPart_000_09EF_01CD28B9.213DC710"
------=_NextPart_000_09EF_01CD28B9.213DC710
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
I know I am doing something wrong here but not really sure why the stored
procedure is failing with a declared variable as the field name
BEGIN
DECLARE boyah VARCHAR(32) DEFAULT 'section17';
SET boyah = 'section17';
SELECT
`translater`.`displayname` AS `displayname`,
`translater`.`scanname` AS `scanname`,
count(`consumables`.`section5`) AS `tcount`
FROM
(`translater` join `consumables` on((`consumables`.`section5` =
`translater`.`scanname`)))
WHERE
((`translater`.`company_id` = company_id) and (`translater`.`dgrup` <>
_utf8'2')
AND
(consumables.boyah BETWEEN nstart AND nstop)
AND
(`consumables`.`section16` >= 1)
AND
(`consumables`.`site_id` = site_id))
GROUP BY
`translater`.`ID`
ORDER BY
`translater`.`displayname`
DESC;
END
If I statically write it in the procedure works perfect, if I try to set a
variable and use that variable as the field name it fails.
Any suggestions???
------=_NextPart_000_09EF_01CD28B9.213DC710--