如何为特定条目替换从 0 到 1 的 MySql 值
How to REPLACE a MySql value from 0 to 1 for specific entries
我想在我的 MySql 数据库中更新或替换(以哪个有效 better/safer 为准)一个 table。
table被称为*editornofollow*
它包含 3 columns:
1. Some unique numerical IDs (I have around 10000 Ids from which only
like 3000 need to be updated)
2. edchoice (no need to replace anythinghere)
3. nofollow (here are values of 0 or 1 - if it's 0 means that the ID attributed to a specific link is dofollowed by search engines, if it's 1 - it's nofollowed).
我想要的是将其中的 3000 个零替换为 1。
命令应该是这样的:
将后面的 if id {id1, id2, id3, id4, id4, id6 etc}
列替换为值 1.
了解 Mysql 的人可以更好地帮助我吗?
我在某个文件中有命令,是几年前由某人完成的,但是...显然我找不到该文件。我只知道这是一个很长的命令,因为它包含所有那些数字 ID。
如果我理解你的问题正确,这应该有效:
UPDATE editornofollow
SET nofollow = 1
WHERE id IN (id1,id2,id3)
您更新 table editornofollow,您将 nofollow 列设置为 1,其中可以在数组 (id1,id2,id3) 中找到 id 列的所有行
如果您需要 select 这些 ID 而不是写入它们,第二,如果您想写入所有这些 ID。
它们中的任何一个都可以工作:)
UPDATE editornofollow
SET nofollow = '0'
WHERE id IN (select ID from ...) //
or
UPDATE editornofollow
SET nofollow = '0'
WHERE id IN (id1,id2,id3 ....) //
我想在我的 MySql 数据库中更新或替换(以哪个有效 better/safer 为准)一个 table。
table被称为*editornofollow*
它包含 3 columns:
1. Some unique numerical IDs (I have around 10000 Ids from which only
like 3000 need to be updated)
2. edchoice (no need to replace anythinghere)
3. nofollow (here are values of 0 or 1 - if it's 0 means that the ID attributed to a specific link is dofollowed by search engines, if it's 1 - it's nofollowed).
我想要的是将其中的 3000 个零替换为 1。
命令应该是这样的:
将后面的 if id {id1, id2, id3, id4, id4, id6 etc}
列替换为值 1.
了解 Mysql 的人可以更好地帮助我吗?
我在某个文件中有命令,是几年前由某人完成的,但是...显然我找不到该文件。我只知道这是一个很长的命令,因为它包含所有那些数字 ID。
如果我理解你的问题正确,这应该有效:
UPDATE editornofollow
SET nofollow = 1
WHERE id IN (id1,id2,id3)
您更新 table editornofollow,您将 nofollow 列设置为 1,其中可以在数组 (id1,id2,id3) 中找到 id 列的所有行
如果您需要 select 这些 ID 而不是写入它们,第二,如果您想写入所有这些 ID。 它们中的任何一个都可以工作:)
UPDATE editornofollow
SET nofollow = '0'
WHERE id IN (select ID from ...) //
or
UPDATE editornofollow
SET nofollow = '0'
WHERE id IN (id1,id2,id3 ....) //