Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/86.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 存储过程中的station/select into时的SQL_Mysql_Sql_Stored Procedures - Fatal编程技术网

Mysql 存储过程中的station/select into时的SQL

Mysql 存储过程中的station/select into时的SQL,mysql,sql,stored-procedures,Mysql,Sql,Stored Procedures,我无法理解为什么下面的SQL过程不会存储在我的数据库中,并且正在报告一个错误,我已经做了很多年了,对此我完全感到困惑 DELIMITER $$ CREATE PROCEDURE add_brand(IN inBrandName TEXT) BEGIN DECLARE brandexists INT DEFAULT 0; SELECT count(*) WHERE BrandName = inBrandName INTO brandexists; IF brandexists = 1 THE

我无法理解为什么下面的SQL过程不会存储在我的数据库中,并且正在报告一个错误,我已经做了很多年了,对此我完全感到困惑

DELIMITER $$
CREATE PROCEDURE add_brand(IN inBrandName TEXT)
BEGIN

DECLARE brandexists INT DEFAULT 0;

SELECT count(*) WHERE BrandName = inBrandName INTO brandexists;

IF brandexists = 1 THEN
select "exists";
ELSE
INSERT INTO tblBrand (BrandName) VALUES (inBrandName);
SELECT LAST_INSERT_ID();
END IF;

END
我得到的错误是:

1064-您的SQL语法有错误;查看与您的MySQL服务器版本对应的手册,以了解在“WHERE BrandName=inBrandName-INTO brandexists”附近使用的正确语法;如果brandexists=1,则在第6行选择'


有什么想法吗?

您缺少一个表格,可以从中进行选择:

SELECT count(*)   WHERE BrandName = inBrandName INTO brandexists;
                ^---here (from some_table)

你错过了一张你可以选择的桌子。哦,天哪。有时候最简单的事情真的会让你失望,不是吗?我现在很尴尬。对不起,浪费了你的时间