Skip to main content
Inspiring
February 26, 2018
Question

Multiple tables in recordset

  • February 26, 2018
  • 1 reply
  • 627 views

Hi,

I'm trying to collect data from two separate tables in the same database.  One table holds the data for the topics and the other holds the data for the replies to that topic.  I want to combine these two so I can output one list that lists the topics posted by a user and the replies made by that same user together in a single recordset. (I'm testing it with '2' as the user_id).  The problem is that I'm seeing double when I test the recordset. This is how I've created the recordset so far:

SELECT boardtopics.user_id as t1_user_id, board_replies.user_id as t2_user_id, boardtopics.title as t1_title, board_replies.title as t2_title

FROM boardtopics, board_replies

WHERE boardtopics.user_id = 2 AND board_replies.user_id = 2

any help would be greatly appreciated.


Thank you,

Michael

This topic has been closed for replies.

1 reply

EddieLotter
Inspiring
February 27, 2018

You need to join your tables.

Read the documentation for your database engine on how to join tables.

Cheers

Eddie