mariadb 声明变量语法错误 [英] mariadb declare variable syntax error

查看:37
本文介绍了mariadb 声明变量语法错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用mariadb和heidisql来执行sql:

Im using mariadb with heidisql to execute sql:

声明@AccountID INT;

DECLARE @AccountID INT;

插入帐户(first_name、mi、last_name、email、is_admin、is_enabled、date_created)值('testfirstname', 'a', 'testlastname', 'user@email.com', 1, 1, NOW());

Insert Into accounts(first_name, mi, last_name, email, is_admin, is_enabled, date_created) Values('testfirstname', 'a', 'testlastname', 'user@email.com', 1, 1, NOW());

设置@AccountID = Last_Insert_Id();

set @AccountID = Last_Insert_Id();

我不断收到错误:

QL 错误 (1064):您的 SQL 语法有错误;检查与您的 MariaDB 服务器版本相对应的手册,以在第 1 行的@AccountID INT"附近使用正确的语法 */

QL Error (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 '@AccountID INT' at line 1 */

我正在查看 Declare 的用法,但它说它用于函数中.我尝试在 DECLARE 之前和之后使用 BEGIN/END,但出现相同的错误.
我是 mysql 语法的新手,这将在 sql server 中工作.所以如果有人可以让我知道我做错了什么,将不胜感激.

I was looking at the usage of Declare but it says that its used in a Function. Ive tried with a BEGIN/END before the DECLARE and after with the same error.
I new to the mysql syntax where this would work in sql server. so if anyone can let me know what i got wrong it would be appreciated.

谢谢

推荐答案

去掉DECLARE.没必要.

这篇关于mariadb 声明变量语法错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆