-1

I'm very new to SQL, so be gentle if I write complete bullshit. I got a phpbb database, where I need to get post_topic and post_text of all topics that are in topics_track from a specific user. My unsuccessful query (again, with basically no knowledge of SQL) is the following:

SELECT post_subject, post_text
FROM phpbb_posts
WHERE topic_id=(ALL topic_id from phpbb_topics_track where user_id='165261')

Can you help me get the right query?

Thank you very much in advance!

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786
  • 2
    To make things clearer, add some sample table data and the expected result (as well formatted text, not images.) – jarlh May 31 '17 at 15:08

1 Answers1

1

That would be

SELECT post_subject, post_text
FROM phpbb_posts
WHERE topic_id = ANY (select topic_id from phpbb_topics_track where user_id='165261');

or

SELECT post_subject, post_text
FROM phpbb_posts
WHERE topic_id IN (select topic_id from phpbb_topics_track where user_id='165261');
Thorsten Kettner
  • 89,309
  • 7
  • 49
  • 73