Results 1 to 8 of 8
Thread: Select from, inner join, where
May 27, 2012, 12:20 #1
- Join Date
- Apr 2011
- Mexico city, Mexico
- 1 Post(s)
- 0 Thread(s)
Select from, inner join, where
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
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 41Do you get bothered because I do the same thing every day?
Do you question why I do it?
Then find something that you actually like doing!!!
Stop thinking on what I do.