Query to find users that update field X

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mobosix
    Senior Member
    • Oct 2003
    • 299
    • 4.2.X

    Query to find users that update field X

    Is there a query that I can run that will tell me which users have update a profile field [fieldx]?

    Thanks.
  • cellarius
    Senior Member
    • Aug 2005
    • 4586
    • 3.8.x

    #2
    SELECT userid FROM userfield WHERE fieldx != 'DEFAULT'

    This will show you users that have set other values than the default value.
    If you have a table prefix change userfield accordingly (for example to vb_userfield).
    Replace the x in fieldx with the number of the userfield (for example field2)
    Replace DEFAULT with the default value of the field; if it's empty by default, set it to ''. (note: this is not one " but two single ').

    Comment

    • mobosix
      Senior Member
      • Oct 2003
      • 299
      • 4.2.X

      #3
      Thanks for the quick reply cellarius. Is there a way to have it output the username and not the userid? I tried replacing userid with username but it did not work.

      Comment

      • cellarius
        Senior Member
        • Aug 2005
        • 4586
        • 3.8.x

        #4
        You'll have to do a join on user table to do this - username is not a valid field in userfield table.

        Try

        Code:
        SELECT user.username
        FROM [COLOR=Red][DB_PREFIX][/COLOR]userfield as userfield 
        LEFT JOIN [COLOR=Red][DB_PREFIX][/COLOR]user as user
        ON  userfield.userid = user.userid
        WHERE field[COLOR=Red]x[/COLOR] != '[COLOR=Red]DEFAULT[/COLOR]'
        Again do the needed replacements.
        Last edited by cellarius; Wed 23 Sep '09, 7:18am.

        Comment

        • mobosix
          Senior Member
          • Oct 2003
          • 299
          • 4.2.X

          #5
          Thanks again for the fast response. What are the variables besides the x? Maybe you could mark them in red in your above code?

          Comment

          • cellarius
            Senior Member
            • Aug 2005
            • 4586
            • 3.8.x

            #6
            [x] done

            My explanations from post nr. 2 still apply.

            Comment

            • mobosix
              Senior Member
              • Oct 2003
              • 299
              • 4.2.X

              #7
              Okay, now how do I find out what my DB prefix is? Sorry, I'm real new to this part of things, but I'm sure others will find it very helpful as well.... so your time will not just be wasted on me 8)

              Comment

              • cellarius
                Senior Member
                • Aug 2005
                • 4586
                • 3.8.x

                #8
                Look for the corresponding setting in includes/config.php. It might be empty "", "vb_" or anything else you set during installation.

                Comment

                • mobosix
                  Senior Member
                  • Oct 2003
                  • 299
                  • 4.2.X

                  #9
                  Okay, that's were I looked. Was not sure if "" was a valid entry. lol

                  Thanks again for all the help!

                  Comment

                  widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
                  Working...