Highlighted

Multiple tables in recordset

Explorer ,
Feb 26, 2018

Copy link to clipboard

Copied

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

TOPICS
Database access

Views

484

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Multiple tables in recordset

Explorer ,
Feb 26, 2018

Copy link to clipboard

Copied

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

TOPICS
Database access

Views

485

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Feb 26, 2018 0
Advocate ,
Feb 27, 2018

Copy link to clipboard

Copied

You need to join your tables.

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

Cheers

Eddie

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 27, 2018 0