How to use Insert .. select, with conditional vars from insert
Posted
by WmasterJ
on Stack Overflow
See other posts from Stack Overflow
or by WmasterJ
Published on 2010-05-21T16:40:12Z
Indexed on
2010/05/21
17:00 UTC
Read the original article
Hit count: 256
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 (picture)
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?
© Stack Overflow or respective owner