I am currently using the follow query:
SELECT *
FROM `wp_usermeta`
WHERE meta_key='avatar'
AND meta_key NOT LIKE '% '
ORDER BY RAND()
LIMIT 4
In that way, I want to try to get only field values, where no empty spaces re in the file name. Where is the error in my query? It still selects filenames with empty spaces in the filename.
Try
Your current wildcard match only catches trailing spaces.
Also, you’re using
meta_keytwice. Should the column used in yourLIKEclause bemeta_value(or whatever it is in WordPress).This question is probably worth reading if you’re concerned about performance – Which is faster — INSTR or LIKE?