XF 1.2 Need some sql query help

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
 
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'
 
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?
 
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:
Top Bottom