PDA

View Full Version : sql error in ... membergroupids like *8*


sandman1970
05-18-2005, 08:04 AM
hi all,

i need to run this sql command for my vB forum:

UPDATE vb3_user SET options=options+512 WHERE !(options & 512) && membergroupids like *8*

the update has hit all users with membergroupids ( a string ), which contains at least one char '8', but saying the truth i know no thing about sql, could anyone correct my mistake in

membergroupids like *8*

syntax? Many thx.

Marco van Herwaarden
05-18-2005, 08:06 AM
AND membergroupids LIKE '%8%'
Keep in mind however that this would also select members who are in group 18.

sandman1970
05-18-2005, 08:17 AM
thx Marco!

at this moment the command will run perfectly, but soonly we will have a group with groupid = 18. What I have to do? I only need to run sql command for all users who are members of group 8?

membergroupids = 8 => update
membergroupids = 11,8,12 => update

membergroupids = 18,11,12 => NOT update

Marco van Herwaarden
05-18-2005, 08:54 AM
Try with the following (try it first with a select statement to see if it is selecting the correct groups):
AND (membergroupids LIKE '8%' OR membergroupids LIKE '%,8%')
I think you wont have any problems then unless you have a usergroup 80.