คำสั่งมันผิดอยู่นิดนึงครับ เผื่อท่านอื่นจะเอาไปใช้
ตามนี้ครับ
select hn,fathername,fatherlname
,left(fathername,instr(fathername,' ')) 'test1'
,substr(fathername,instr(fathername,' ')+1) 'test2'
from patient
where locate(' ',trim(fathername))>1
limit 1000
select hn,mathername,motherlname
,left(mathername,instr(mathername,' ')) 'test1'
,substr(mathername,instr(mathername,' ')+1) 'test2'
from patient
where locate(' ',trim(mathername))>1
limit 1000
.........
1.update patient set fatherlname=fathername where locate(' ',trim(fathername))>1
2.update patient set fatherlname=left(fathername,instr(fathername,' ')),fatherlname=substr(fatherlname,instr(fatherlname,' ')+1) where locate(' ',trim(fathername))>1
1.update patient set motherlname=mathername where locate(' ',trim(mathername))>1
2.update patient set motherlname=left(mathername,instr(mathername,' ')),matherlname=substr(matherlname,instr(matherlname,' ')+1) where locate(' ',trim(mathername))>1