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

SQL query to transfer info between fields?

Discussion in 'XenForo Questions and Support' started by fredrikse, Oct 7, 2012.

  1. fredrikse

    fredrikse Active Member


    I'm in need of a query that can transfer information between imported vB custom fields and newly created XenForo custom fields. The information is text or numeric values.
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    INSERT INTO xf_user_field_value (user_id, field_id, field_value)
    	SELECT user_id, 'new_field_id', field_value
    	FROM xf_user_field_value
    	WHERE field_id = 'old_field_id'
    	field_value = VALUES(field_value);
    Then rebuild the user cache:

    Admin CP -> Tools -> Rebuild Caches -> Rebuild User Caches
    fredrikse likes this.
  3. fredrikse

    fredrikse Active Member

    This is great. Since I used swedish words for the field names in vBulletin I'm going to create new ones with english field IDs and transfer all information correspondingly.

    What would the query look like if I want to transfer information from a custom field to, let's say for instance, the "about" field in XenForo?
  4. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    UPDATE xf_user_profile AS up
    SET up.about = (
    	SELECT ufv.field_value
    	FROM xf_user_field_value AS ufv
    	WHERE ufv.user_id = up.user_id
    	AND ufv.field_id = 'old_field_id'
    fredrikse likes this.

Share This Page