There is also this, which gives examples of building custom queries https://codex.wordpress.org/Displaying_Posts_Using_a_Custom_Select_Query
Unfortunately that also does not show how to do anything with related posts.
To be honest, while I’ve had a lot of experience in the past with SQL, I’ve never tried to do custom queries like this and have always depended on WP_Query. I’m also finding that it has it’s limitations and have been trying to work out how to use it myself. I have a project coming up that’s going to require exactly what you’re doing.
It will have a “Product” or “Inventory” post type and a “Specs” post type where each “Spec” can be associated with one or more products and then there will be a parametric search that searches these specs and show the products.
But I have not found any information specific to this and I’ve been looking for a while. I’d say to ask over on the WP forums, you could get lucky, or maybe stack exchange http://wordpress.stackexchange.com/
I’m going to be digging into this some more. If I figure anything out I’ll do my best to remember this discussion and post what I find.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!