如果字段为0000,我需要获得字段的最大值+1。
IF
(acc_id = 0000)
FROM
crm_accounts;
INSERT
INTO
crm_accounts(acc_id)
SELECT MAX
(acc_id) + 1
FROM
crm_accounts;
答案 0 :(得分:1)
我认为您正在寻找UPDATE
声明...
这应该为你完成:
SELECT @id := MAX(acc_id) FROM crm_accounts;
UPDATE crm_accounts
SET acc_id = @id := @id + 1
WHERE acc_id = 0000;