我想使用另一个变量引用变量。基本上我有7个地址字段(address1,address2等),它可以节省大量编码,从1到7进行循环。这是我需要的基本情况:
Naddress1 = replace(Naddress1,'.','');
Naddress2 = replace(Naddress2,'.','');
Naddress3 = replace(Naddress3,'.','');
Naddress4 = replace(Naddress4,'.','');
Naddress5 = replace(Naddress5,'.','');
Naddress6 = replace(Naddress6,'.','');
Naddress7 = replace(Naddress7,'.','');
Naddress1 = replace(Naddress1,',',' ');
Naddress2 = replace(Naddress2,',',' ');
Naddress3 = replace(Naddress3,',',' ');
Naddress4 = replace(Naddress4,',',' ');
Naddress5 = replace(Naddress5,',',' ');
Naddress6 = replace(Naddress6,',',' ');
Naddress7 = replace(Naddress7,',',' ');
Naddress1 = replace(Naddress1,'/'',' ');
Naddress2 = replace(Naddress2,'/'',' ');
Naddress3 = replace(Naddress3,'/'',' ');
Naddress4 = replace(Naddress4,'/'',' ');
Naddress5 = replace(Naddress5,'/'',' ');
Naddress6 = replace(Naddress6,'/'',' ');
Naddress7 = replace(Naddress7,'/'',' ');
我想要的是什么:
DECLARE address_iterator INT;
SET address_iterator = 1;
WHILE address_iterator <= 7 DO
Naddress & address_iterator = replace(Naddress & address_iterator, '.','');
Naddress & address_iterator = replace(Naddress & address_iterator, ',',' ');
Naddress & address_iterator = replace(Naddress & address_iterator, '/'',' ');
END WHILE;
答案 0 :(得分:0)
在MySQL中你可以做这样的事情 -
UPDATE
table
SET
address1 = REPLACE(REPLACE(REPLACE(address1, '.', ''), ',',' '), '/',' '),
address2 = REPLACE(REPLACE(REPLACE(address2, '.', ''), ',',' '), '/',' '),
address3 = REPLACE(REPLACE(REPLACE(address3, '.', ''), ',',' '), '/',' ');
否则,您应该在应用程序中自动执行此任务。