vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Query Help: Select users who are members of X group (https://vborg.vbsupport.ru/showthread.php?t=154384)

steveheinsch 08-05-2007 07:04 PM

Query Help: Select users who are members of X group
 
I am coding a small app for a client that will allow them to edit certain added fields to the users table. What I am needing is to return all users who are a member of usergroup X (BOTH Primary and Additional Usergroups need to be checked for X).

I know you can do this with a vB function to check if the current logged in user is a member of a group like:
PHP Code:

if (is_member_of($vbulletin->userinfoXYZ

Where X Y and Z are a usergroup level. That function checks BOTH 'usergroupid' and 'membergroupids' fields for X Y and Z.

I am needing some SQL like:

SELECT * FROM user WHERE usergroupid = '$level_to_check' OR membergroupids "contains $level_to_check"

The "contains $level_to_check" part is where I am stuck as membergroupids contains data like "4,7,12" and I do not know how to efficiently check for a certain value with data stored in that format.

HELP! Thank you...This is driving me crazy.

-Steve

Paul M 08-05-2007 08:53 PM

Look up the mysql FIND_IN_SET() function.


All times are GMT. The time now is 02:42 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.00994 seconds
  • Memory Usage 1,708KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (2)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete