1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XF 1.2 Need some sql query help

Discussion in 'XenForo Questions and Support' started by Itworx4me, Jan 11, 2014.

  1. Itworx4me

    Itworx4me Well-Known Member

    I have a custom field named 'nick_name'. I need to query the database to find all users that don't have this field filled in. Can someone help with the sql query?

    Thanks,
    Itworx4me
     
  2. Itworx4me

    Itworx4me Well-Known Member

    Figured out part of the query. Now I just need to figure out how to query the table for people that don't have the field_value filled in..
    Code:
    SELECT `user_id`, `field_id`, `field_value`
    FROM `xf_user_field_value`
    WHERE `field_id` =  'nick_name'
     
  3. Itworx4me

    Itworx4me Well-Known Member

    ok I figure out how many people don't have the field_value filled in.
    Code:
    SELECT `user_id`, `field_id`, `field_value`
    FROM `xf_user_field_value`
    WHERE `field_id` =  'nick_name' AND `field_value` =''
    Now I need to update the field_value that isn't filled in with a value. How would I go about this?
     
  4. Itworx4me

    Itworx4me Well-Known Member

    Would this be the correct use of Update?
    Code:
    UPDATE `xf_user_field_value`
    SET `field_value`=[John Doe]
    WHERE `field_value` = ''
    Or
    Code:
    UPDATE `xf_user_field_value`
    SET `field_value`= John Doe
    WHERE `field_value` = ''
    Or
    Code:
    UPDATE `xf_user_field_value`
    SET `field_value`='John Doe'
    WHERE `field_value` = ''
    Not sure which one to use.....
     
    Last edited: Jan 11, 2014
  5. Brogan

    Brogan XenForo Moderator Staff Member

    Code:
    UPDATE <table> SET <column> = REPLACE(<column>,'current_content','new_content');
     
    Itworx4me likes this.

Share This Page