PDA

View Full Version : Combine a SELECT and an UPDATE?


MPDev
10-05-2005, 09:11 PM
I'd like to NULL user signatures which contain [img] tags for "regular users". I have a query:

SELECT u.userid, u.username, t. * FROM usertextfield t
LEFT JOIN user u ON u.userid = t.userid
WHERE t.signature LIKE '%[img]%' AND u.usergroupid=2

but am unsure how to execute an UPDATE on these records (over 140).

Is there a way to combine an UPDATE with the results on this query without writing a script?

UPDATE

Well, after playing around I finally got this to work:

update user,usertextfield set usertextfield.signature=NULL where user.userid=usertextfield.userid AND usertextfield.signature LIKE '%[img]%' AND user.usergroupid=2;