gpt4 book ai didi

mySql Query 在查询浏览器中工作,但在 CFquery 中运行时失败

转载 作者:行者123 更新时间:2023-11-29 07:14:55 26 4
gpt4 key购买 nike

起初我以为我遇到了 cfqueryparam 和 mysql 的问题。但是,当我用静态值替换它们时,我得到了同样的错误。这让我很难过,我猜我已经习惯了 Microsoft SQL Server。任何帮助将不胜感激。

这是查询,它在 mySql 查询浏览器中完美运行,但在 cfquery 中运行时失败:

LOCK TABLE categories WRITE;

SELECT @myRight := rgt FROM categories WHERE catid = <cfqueryparam cfsqltype="cf_sql_integer" value="#parentCategoryId#">;

UPDATE categories SET rgt = rgt + 2 WHERE rgt > @myRight;
UPDATE categories SET lft = lft + 2 WHERE lft > @myRight;

INSERT INTO categories(categoryName, lft, rgt) VALUES(<cfqueryparam cfsqltype="cf_sql_varchar" value="#newCatName#">, @myRight, @myRight + 2);

UNLOCK TABLES;

我收到以下错误:

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 'SELECT @myRight := rgt FROM categories WHERE catid = 5; UPDATE categories SE' at line 2

VENDORERRORCODE:1064SQL State: 42000

最佳答案

除非你在你的 MySQL 服务器上明确允许它,否则你不能在同一个 cfquery 中有多个 sql 语句。 MySQL 默认拒绝这一点,因此您的每个更新和插入语句都必须位于它们自己的 cfquery 标记中。

关于mySql Query 在查询浏览器中工作,但在 CFquery 中运行时失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1986240/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com