在pw_members表里
uid username
42 lbj
43 xxk
44 fghj
.....在pw_posts表里
author authorid
lbj 0
xxk 0
fghj 0
.....请问如何用sql语句 把uid的值更新到authorid里呢?
使pw_posts结果为
author authorid
lbj 42
xxk 43
fghj 44
uid username
42 lbj
43 xxk
44 fghj
.....在pw_posts表里
author authorid
lbj 0
xxk 0
fghj 0
.....请问如何用sql语句 把uid的值更新到authorid里呢?
使pw_posts结果为
author authorid
lbj 42
xxk 43
fghj 44
from pw_members where username=author
update pw_posts set authorid=(select uid from pw_members where username=pw_posts.author)
update pw_posts set authorid=uid from pw_posts a,pw_members b
where a.username=b.author
set authorid=uid
from pw_posts a,pw_members b
where a.username=b.author