ฉันต้องการอัปเดต / แทนที่ข้อมูลตารางโดยใช้ไฟล์แบตช์ และฉันเก็บ old_data ไว้ในไฟล์ old.txt และ new_data ในไฟล์ new.txt
old.txt:
101
India
new.txt:
1001
0891
และนี่คือแบทช์สคริปต์ของฉัน: demo.bat
@echo off
for /f "tokens=1* delims= " %%a in (old.txt) do (
for /f "tokens=1* delims= " %%b in (new.txt) do (
mysql -u root -p tiger -host localhost -database empsrc -e "update table_name set col_name='%%b' where col_name='%%a'"
)
)
pause
เมื่อฉันรันไฟล์แบตช์ข้างต้น
101 is replaced with 1001 and
india is also replaced with 1001
แต่ผลลัพธ์ที่คาดหวังของฉันคือ
101 is replaced with 1001
India should be replaced with 0891
ฉันจะแก้ปัญหานี้อย่างไร บางคนสามารถช่วยฉันได้โปรด