
February 1st, 2013, 04:25 AM
|
|
Contributing User
|
|
Join Date: Jan 2010
Posts: 75
Time spent in forums: 15 h 7 m 39 sec
Reputation Power: 4
|
|
|
Join on latest row only
I am trying to join on a row from the wp_comments sta table.
However this is a status table and contains many rows for each order.
I only want to check if the comments on the latest row = changed form pending to processing and if so, then I want to bring back a record for the wp_posts ord table.
If the latest row in wp_comments sta = any other text, then I do not want to bring the record back.
Any ideas how I can do this? The current SQL brings back everything
SELECT*
FROM wp_posts ord
INNERJOIN wp_comments sta ON ord.ID = sta.comment_post_ID
WHERE ord.post_type LIKE'shop_order'
AND sta.comment_content LIKE'%changed from pending to processing%'
LIMIT 0 , 30
|