Answers.Body: <p>It will be in a table called something like <code>civicrm_value_ocsr_12</code> and the fieldname will look something like <code>langue_57</code>. You want to join on the <code>entity_id</code> column, e.g.</p>
  
  <p><code>update civicrm_contact c left join civicrm_value_ocsr_12 v ON v.entity_id = c.id set c.preferred_language = 'fr_FR' where v.langue_57='F';</code></p>
  
  <p>(I haven't tested that, just writing out the theory - I always get mixed up trying to get the right syntax for joins in an update statement.)</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-06-02T17:23:45.400Z
Answers.LastActivityDate: 2020-06-02T17:23:45.400Z
Answers.UserDisplayName: Demerit
Body: <p>I have imported hundreds of contacts having a custom field called "Langue" in set "ocsr" and having two possible values, 'F' and 'N'. I want to transfer this information into the field preferred language, with values 'fr_FR' and 'nl_NL'.</p>
  
  <p>I suppose it is possible to do it in one Mysql operation, but I don't find where the custom field value is stored:</p>
  
  <pre><code>update civicrm_contact set preferred_language = 'fr_FR' where ... ocsr::Langue ... = 'F'
  </code></pre>
  
  <p>Any hint would be appreciated.</p>
  
Tags: <custom-fields><mysql>
Title: How to update preferred language depending on a custom field in imported contacts?
ThreadText: # How to update preferred language depending on a custom field in imported contacts?
  
  (Asked by: username_0 on 2020-06-02)
  
  I have imported hundreds of contacts having a custom field called "Langue" in set "ocsr" and having two possible values, 'F' and 'N'. I want to transfer this information into the field preferred language, with values 'fr\_FR' and 'nl\_NL'.
  
  I suppose it is possible to do it in one Mysql operation, but I don't find where the custom field value is stored:
  
  ```
  update civicrm_contact set preferred_language = 'fr_FR' where ... ocsr::Langue ... = 'F'
  
  ```
  
  Any hint would be appreciated.
  
  **Tags:** custom-fields, mysql
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-06-02. Score: 1 | Accepted answer
  
  It will be in a table called something like `civicrm_value_ocsr_12` and the fieldname will look something like `langue_57`. You want to join on the `entity_id` column, e.g.
  
  `update civicrm_contact c left join civicrm_value_ocsr_12 v ON v.entity_id = c.id set c.preferred_language = 'fr_FR' where v.langue_57='F';`
  
  (I haven't tested that, just writing out the theory - I always get mixed up trying to get the right syntax for joins in an update statement.)
  
  
  ---
  
  