第1行的'0'附近的MySQL SQL语法错误

时间:2017-06-02 15:28:23

标签: mysql string stored-procedures where-clause concat

我已经尝试了各种修改来使这项工作,但我似乎无法删除错误。我的SQLQuery字符串比下面的字符串大得多但设置相同。我尝试使用CONCAT(' ')语句,但遇到了问题。所以我尝试使用这种格式,但仍然收到相同的错误。有什么建议吗?

CREATE DEFINER=`root`@`%` PROCEDURE `stp_Select_GetTbl`(IN strWhereClause 
VARCHAR(255))
BEGIN
DECLARE SQLQuery varchar(1000); 

SET SQLQuery = '
SELECT `Part Num` AS `PPNumber`,
`Shop Num` as `SOrder`
FROM `track`.`s list` WHERE ';

SET @SQLQuery = @SQLQuery + strWhereClause + '';

PREPARE stmt FROM @SQLQuery;
EXECUTE stmt;
END

错误:

`Error Code: 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 '0' at line 1

` 我试图不声明SQLQuery ...改变varchar大小......重新组织甚至使用下面的例子

SET @getList =
CONCAT('SELECT (t1, t2, t3) FROM (SELECT t1, t2, t3) as mainSelect WHERE ', strWhereClause, '');

PREPARE stmt FROM @getList;
EXECUTE stmt;
END

但是得到错误     .... MySQL server version for the right syntax to use near '0

我需要为SELECT语句定义一个字符串,因为我在存储过程中创建了WHERE子句。

0 个答案:

没有答案