【问题标题】:Mysql Stored Procedure ErrorMysql存储过程错误
【发布时间】:2016-02-08 12:13:53
【问题描述】:

请帮助:

DELIMITER $$

CREATE PROCEDURE `getTodayCheckOuts`
BEGIN
    SELECT `tec_check_out`.`date`,`tec_check_out_items`.`check_out_id`,`tec_check_out_items`.`item_id`,CONCAT(`tec_items`.`name`,' - ',`tec_items`.`code`) AS 'name',SUM(`tec_check_out_items`.`quantity`) AS 'totla_qty',SUM(`tec_check_out_items`.`quantity`*`tec_check_out_items`.`price`) AS 'total_price'
    FROM `tec_check_out_items`, `tec_items`, `tec_check_out`
    WHERE `tec_check_out_items`.`item_id`=`tec_items`.`id`
    AND `tec_check_out_items`.`check_out_id`=`tec_check_out`.`id`
    AND DATE(`tec_check_out`.`date`) = DATE(NOW())
    GROUP BY `tec_check_out_items`.`item_id`
END $$

DELIMITER ;

不断收到此错误

Error
Static analysis:
2 errors were found during analysis.

Unrecognized data type. (near "." at position 163)
Unrecognized data type. (near "," at position 176)

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'BEGIN
    SELECT `tec_check_out`.`date`,`tec_check_out_items`.`check_out_id`,`tec_' at line 2

【问题讨论】:

  • 你能提到位置 163 和 176 指向的位置...吗??

标签: php mysql sql stored-procedures


【解决方案1】:

变化:

/*
CREATE PROCEDURE `gettodaycheckouts`
*/

作者:

CREATE PROCEDURE `gettodaycheckouts`()

/*
GROUP BY `tec_check_out_items`.`item_id`
*/

作者:

GROUP BY `tec_check_out_items`.`item_id`;

【讨论】:

  • 感谢工作,但现在不断收到此错误:unexpected character (;) near GROUP BY tec_check_out_items.item_id;
猜你喜欢
  • 2023-03-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-03-28
相关资源
最近更新 更多