Need Help with modifying MySQL query code

Discussion in 'MySQL' started by eddiemoth, Dec 28, 2011.

  1. #1
    Hi all,
    I like to exclude a few users from displaying on the Mod_Topmembers by JomSocial.

    Below is the query code. Can someone help me to add a clause where I can exclude Userid = 42,43, etc. ? I appreciate it.

    
    
    class modTopMembersHelper
    {
       function getMembersData( &$params )
       {
          $model   =& CFactory::getModel( 'user' );
          $db    =& JFactory::getDBO();
          
          $limit   = $params->get('count', '5');
          
          $query   = 'SELECT ' . $db->nameQuote( 'userid' ) . ' FROM ' . $db->nameQuote( '#__community_users' ) . ' AS a '
                . ' INNER JOIN ' . $db->nameQuote( '#__users' ) . ' AS b ON a.' . $db->nameQuote('userid').'=b.' . $db->nameQuote('id')
                . ' WHERE ' . $db->nameQuote('thumb') . '!=' . $db->Quote('components/com_community/assets/default_thumb.jpg') . ' '
                . ' AND ' . $db->nameQuote( 'block' ) . '=' . $db->Quote( 0 ) . ' '
                . ' ORDER BY ' . $db->nameQuote( 'points' ) . ' DESC '
                . ' LIMIT ' . $limit;
    
    
    
    Code (markup):
     
    eddiemoth, Dec 28, 2011 IP
  2. Basti

    Basti Active Member

    Messages:
    625
    Likes Received:
    6
    Best Answers:
    3
    Trophy Points:
    90
    #2
    Below
    
                . ' AND ' . $db->nameQuote( 'block' ) . '=' . $db->Quote( 0 ) . ' '
    
    PHP:
    try adding
    
                . ' AND ' . $db->nameQuote( 'userid' ) . ' NOT IN (42,43,44,45,46) '
    
    PHP:
    Never used Jomsocial/joomla, but i think this should work
     
    Basti, Dec 28, 2011 IP
  3. eddiemoth

    eddiemoth Peon

    Messages:
    75
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thank you so much Basti that works like a charm!
     
    eddiemoth, Dec 28, 2011 IP
  4. Basti

    Basti Active Member

    Messages:
    625
    Likes Received:
    6
    Best Answers:
    3
    Trophy Points:
    90
    #4
    Good it worked on the first try :)
     
    Basti, Dec 29, 2011 IP
  5. mmerlinn

    mmerlinn Prominent Member

    Messages:
    3,197
    Likes Received:
    819
    Best Answers:
    7
    Trophy Points:
    320
    #5
    Nothing ever works on the first try. What kind of magic do you practice?
     
    mmerlinn, Jan 7, 2012 IP