The code found in the documentation below does not work when the $ids = []. This is the case when no data is returned and 'post__in' filter does nothing. This may need to be modified. There is also a typo in the documentation. The first line has $ids but in the query, $id is used.
global $wpdb;
$ids = $wpdb->get_col( "SELECT ID FROM your_table WHERE field1 = 'value1' OR field2 = 'value2'" );
$query = new WP_Query( [
'post_type' => 'post',
'post__in' => $id,
] );