N
N
naneri2014-08-26 09:00:11
MySQL
naneri, 2014-08-26 09:00:11

How in MySQL to make conditions for selection in two tables?

There are two tables, one contains users' topics, and the other contains comments on topics and the status of topics (active \ not) Like
this:
Topics:
topic_id | user_id
Comments:
comment_id | topic_id | active
topic id of two tables linked. How to write a query so that it gives out all the info of comments and topics for topics whose user_id = 2 and comment status active = 1?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
KurazhBambei, 2014-08-26
@naneri

SELECT *
FROM topics t, comments c
WHERE t.topic_id = c.topic_id AND t.user_id = 2 AND c.active = 1

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question