假设我有桌子'项目'
表'items'中有500行
我想添加一个新列“新”。
行1 - 100需要在“新”列中具有“A”,
行101 - 200需要在“新”列中具有“B”,
第201-300行需要在“新”列中包含“C”
等等。
这样:
是否有mysql查询可以执行以下操作:
UPDATE items WHERE rows 1 THROUGH 100 (UPDATE 'A' IN new)
答案 0 :(得分:1)
试试这个:
1-100
UPDATE table
set new = 'A'
where id in
(
Select temp.Id from
(
Select id as Id from table limit 1,100
) as temp
)
101-200
UPDATE table
set new = 'B'
where id in
(
Select temp.Id from
(
Select id as Id from table limit 101,100
) as temp
)