我在MSSQL中有这个SQL:
SELECT
(LEN(article) - LEN(REPLACE(article, ' ', ''))) + 1
FROM articles
如何获取这些结果并更新字段' wordcount'在表'文章'?
答案 0 :(得分:4)
您可以将此表达式放在update
:
update articles a
set wordcount = (LEN(article) - LEN(REPLACE(article, ' ', ''))) + 1;