View Full Version : Need help with a query
MuSuL
08-16-2005, 05:10 PM
I'm looking to write a script that will change all the IP addy's of a usergroup when run. I kinda have an idea how to do it but not 100% sure. This is what I've come up with.
UPDATE post
SET ipaddress = '0.0.0.0'
WHERE userid in
(
SELECT post.userid
FROM [user] INNER JOIN post ON user.UserID = post.userid
WHERE groupid = 5
)
Would this work?
Colin F
08-16-2005, 05:42 PM
I'm looking to write a script that will change all the IP addy's of a usergroup when run. I kinda have an idea how to do it but not 100% sure. This is what I've come up with.
UPDATE post
SET ipaddress = '0.0.0.0'
WHERE userid in
(
SELECT post.userid
FROM [user] INNER JOIN post ON user.UserID = post.userid
WHERE groupid = 5
)
Would this work?
As that uses subqueries, you'll have to check what version of mysql the server is running. Subqueries are only supported by more recent versions.
I also don't understand the brackets around user
Marco van Herwaarden
08-16-2005, 08:50 PM
And in the subquery select it would be user.userid, not post.userid. Out of my had it is also usergroupid and not groupid.
MuSuL
08-16-2005, 10:21 PM
Thanks for the help. The brackets were because I was running the query in Access to test.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.