I have two separate tables both with user id columns uid
. I want to take a value from all users in one table and insert it into the correct row for the correct user in the other table.
INSERT INTO users2 (p开发者_Python百科icture)
SELECT pv.value
FROM profile_values as pv, users2 as u
WHERE pv.uid = u.uid
AND pv.fid = 31
AND users2.uid=u.uid;
But it's not working because i seem not to have access to users2.uid inside of the select statement.
How would I accomplish this?
You should be able to access your u
alias for users2
fine. Direct access to users2
isn't possible because you're INSERT
ing into it, so the row doesn't actually exist yet. Do you want to do an insert
or update
?
精彩评论