Site icon Hip-Hop Website Design and Development

Plugin MySQL SELECT custom data and filter on user meta

I’m porting a custom PHP feature to be part of a WordPress plugin.

At present, my USERS table has a field (let’s call it FLAG) which my MySQL query needs to filter on, eg:

SELECT custom-data
  FROM custom-table JOIN users ON some-match
 WHERE some-condition AND users.flag='1'
 GROUP BY username

Obviously, within my WordPress plugin, I have implemented flag as user-meta.

But how can I use this in a MySQL query?