Looking for query to find where two members posted in same thread

AndyB

Well-known member
I'm looking for query to find where two members posted in same thread. So far I have created this query but it does not retrieve any results.

Code:
SELECT xf_thread.thread_id
FROM xf_thread
INNER JOIN xf_post ON xf_post.thread_id = xf_thread.thread_id
WHERE xf_post.user_id='1'
AND xf_post.user_id='2'
 
Your query is looking for a post where the posters ID (xf_post.user_id) is both 1 & 2. This is impossible.
 
I posted the question at Stack Overflow and here's the MySQL query that works perfectly.

Code:
SELECT thread_id
FROM xf_post
group by thread_id
having max(user_id='1') > 0
and max(user_id='2') > 0
 
Top Bottom