Don't query the database directly to get product custom meta
Instead get the post meta, and filter out unwanted values.

Note that the meta_id and post_id are no longer in the meta values array elements.