Hello,

I am trying to select a row that matches a specific id but I'm having trouble where it pulls 29 results when there is only one, basically I have an Id and, based on that id, I would like to check against another table, if the id has a match pull the row, here is my query

Code SQL:
SELECT 
wp_posts . * , 
wp_p2p.p2p_to AS connected
FROM wp_posts
INNER JOIN 
wp_p2p ON wp_p2p.p2p_to = wp_posts.ID
WHERE
wp_posts.post_type = 'post_ad'
AND
wp_p2p.p2p_to = wp_posts.ID

The setup is like this

I have a post with id 40 and a post with id 41 in the table wp_posts
In the table wp_p2p I have a row with 2 fields from and to from has the value 41 and to has the value 40
Given the fact that I know the value 40 I need to go to the table wp_p2p retrieve value 41 so I can select from the table wp_posts the row with id 41