mysql – How to search usermeta table

What is the best way to search usermeta to find a user_id based on a meta_value? For example in usermeta table there is a row with user_id = 123 , meta_key = deviceid and meta_value = 45545.
I know the deviceid and I need to find out what user_id is associated with it.
I tried (amongst a million other things) this:

$scaleData = json_decode($reading, TRUE);
$deviceid = $scaleData("imei");
$WhoIsUser = $wpdb->get_var(  $wpdb->prepare("SELECT user_id FROM wp_6cwmmr_usermeta WHERE meta_value = '$deviceid' "));
echo $WhoIsUser ;

I know this is too simple. (fwiw $deviceid does return a valid string.)