请帮忙......
UPDATE transactions SET `tr_code` =
(SELECT CONCAT(SUBSTRING_INDEX(tr_code, '-',
(LENGTH(tran.tr_code) - LENGTH( REPLACE(tran.tr_code, '-', '' ) ) ) ), '-' , tran.id) FROM transactions tran
WHERE tran.id = 710) WHERE id = 710;
答案 0 :(得分:0)
您根本不需要子查询:
UPDATE transactions
SET `tr_code` = CONCAT(SUBSTRING_INDEX(tr_code, '-',
LENGTH(tr_code) - LENGTH(REPLACE(tr_code, '-', '' ))
), '-' , id
)
WHERE id = 710;