• 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

Itworx4me

Well-known member
#1
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
 

Itworx4me

Well-known member
#2
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'
 

Itworx4me

Well-known member
#3
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?
 

Itworx4me

Well-known member
#4
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: