I don't know if this is the best way but it works. I did this:
$id is from the URL
$postId = DB::connection('mysql_second')->table('wp_postmeta')
->where('wp_postmeta.meta_value', $id)->value('post_id');
I then placed that into my other query:
WHERE wp_posts.post_type = 'm6_projects' AND wp_posts.ID = :postId
Would that be the best way?