SELECT * FROM xf_user_field_value WHERE field_id(Varbinary)

Rayman

Member
I am trying to run the following query but it won't pick anything up since field_id is a varbinary field which has data that isn't recognized as a 'string'.

Code:
$users = $db->fetchAll("
       SELECT
         xf_user.user_id,xf_user.username,xf_user.user_group_id,xf_user.secondary_group_ids
       FROM
         `xf_user`
       INNER JOIN
         `xf_user_field_value` ON (xf_user_field_value.user_id = xf_user.user_id)
       WHERE
         xf_user.user_group_id='3' AND xf_user_field_value.field_id = '6469766973696f6e'
     ");

Does anyone know a way around it?

I know that this function exists (getUserFieldValues($userId)) but since that would require me to use it in a for loop that would run almost 1000 times, its just too many queries from that function - hence why I'd rather use my query above, which would run once.

Many thanks!
 
Just use the Filed Id you want to fetch such as 'skype' or 'twitter'.
You may also want to check that the filed has an actual value.
 
Back
Top Bottom