需要正确的 sql 命令来删除 CHAR_LENGTH() 超过的地方

发布于 2024-11-19 13:49:53 字数 677 浏览 2 评论 0原文

我需要正确的 SQL 命令来删除 CHAR_LENGTH() 超过我尝试过的 x 数量

TRUNCATE * FROM foo WHERE CHAR_LENGTH(foobar) > 100

(也尝试过 DELETE *)

,根据 w3cshools 是一个有效的运算符,但它只是返回错误:

> #1064 - 你的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,了解在 ' FROM foo WHERE CHAR_LENGTH(foobar) > 附近使用的正确语法。 100' at line 1*

注意:错误消息实际上显示 >作为 ASCII“>” (没有空格或引号)不确定这是否有任何相关性...

我也尝试过:

SELECT * FROM foo WHERE CHAR_LENGTH(foobar) > 100

只是为了看看这是否会做任何事情,它做了预期的事情,并显示所有字符计数大于 100。

一如既往,我们感谢任何帮助。

I need the correct SQL command to delete where CHAR_LENGTH() more than x amount I tried

TRUNCATE * FROM foo WHERE CHAR_LENGTH(foobar) > 100

(also tried DELETE *)

which according to w3cshools is a valid operator but it just comes back as error:

> #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 ' FROM foo WHERE CHAR_LENGTH(foobar) > 100' at line 1*

Note: The error message actually shows > as ASCII "& gt;" (no space or quotes) not sure if that has any relevance ...

I also tried:

SELECT * FROM foo WHERE CHAR_LENGTH(foobar) > 100

Just to see if that would do anything and it did what was expected and showed all with a charcount greater then 100.

As always any help is appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

缺⑴份安定 2024-11-26 13:49:53

我认为您正在寻找 DELETE 操作,而不是 截断

DELETE FROM foo WHERE CHAR_LENGTH(foobar) > 100;

TRUNCATE 具有以下语法:

TRUNCATE foo;

并完全清空表。 TRUNCATE 上不能有 WHERE 子句。

I think you are looking for the DELETE operation, not TRUNCATE.

DELETE FROM foo WHERE CHAR_LENGTH(foobar) > 100;

TRUNCATE have this syntax:

TRUNCATE foo;

and empties the table completely. You cannot have a WHERE clause on TRUNCATE.

一杆小烟枪 2024-11-26 13:49:53

您不能将 TRUNCATE TABLE 与 where 子句一起使用 (Ref。)

使用DELETE< /代码>反而:

DELETE FROM foo WHERE CHAR_LENGTH(foobar) > 100 

You can't use TRUNCATE TABLE with a where clause (Ref.)

Use DELETE instead:

DELETE FROM foo WHERE CHAR_LENGTH(foobar) > 100 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文