0
我想使用另一個變量引用一個變量。基本上,我有7個地址字段(地址1,地址等),這將節省編碼,使一個循環,從1到7的很多這裏有一個基本的情況,我需要這樣的:MySQL存儲過程,帶變量名稱的變量
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,'/'',' ');
我」什麼D類似於:
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;
忘記提及這是在存儲過程中,但這個答案有很大幫助!謝謝 – user1630799