L
L
lemonlimelike2017-07-10 22:53:29
MySQL
lemonlimelike, 2017-07-10 22:53:29

How to make such a query in the database?

The essence of the request is as follows: There is a video on the main page, at the bottom of it I make the "Related Videos" block. So, you need to select all videos from the videos table (in this block), but they must be of the same category as the main video. What to do?
The db structure is here:
52d28e83c23c43bcba2da9db09ad35b5.jpg292e26f92d29447fb7e207f27c27de68.jpgcecf2d90d6034ffe9b856c7bd94e83b6.jpg

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stalker_RED, 2017-07-10
@lemonlimelike

SELECT * FROM videos
WHERE id IN (
     SELECT video_id FROM video_category
     WHERE category_id=3
)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question