I need to customize SQL query in wpDataTables to create a table from custom post type 'stock' that have acf fields, so I have two tables: 5s_posts and 5s_postmeta. This code shows up row with meta key trade_in and it's meta value. But I need to retrieve all meta key and it's values table 5s_postmeta that coresponds to post ID from 5s_posts.
SELECT meta_value AS 'trade_in'FROM 5s_postmeta WHERE meta_key = 'trade_in' AND post_id IN(SELECT ID FROM 5s_posts WHERE post_type = 'stock' AND post_status = 'publish')
5s_postmeta table exemple: 5s_postmeta table exemple
5s_posts table exemple: