需要正确的 sql 命令来删除 CHAR_LENGTH() 超过的地方
我需要正确的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为您正在寻找 DELETE 操作,而不是 截断。
TRUNCATE 具有以下语法:
并完全清空表。 TRUNCATE 上不能有 WHERE 子句。
I think you are looking for the DELETE operation, not TRUNCATE.
TRUNCATE have this syntax:
and empties the table completely. You cannot have a WHERE clause on TRUNCATE.
您不能将
TRUNCATE TABLE
与 where 子句一起使用 (Ref。)使用
DELETE< /代码>
反而:
You can't use
TRUNCATE TABLE
with a where clause (Ref.)Use
DELETE
instead: