Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7060107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:18:46+00:00 2026-05-28T04:18:46+00:00

I got a users table and movies table, each user could watch more then

  • 0

I got a users table and movies table, each user could watch more then one movie.

Now I want to find all the users who watched particular movie,
How should my tables looks like in MySql?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T04:18:47+00:00Added an answer on May 28, 2026 at 4:18 am

    To do this, you need 3 tables. The first two are users and movies, they would, in a very basic form, look like this:

    user
      id
      name
    
    movie
      id
      title
    

    Since many users can watch many movies and the same movie can be watched by multiple users, there’s a many-to-many relationship there. To define such a relationship in MySQL, you need a third table called a join table, that knows which user watched which movie (I called this user_movies but you might want to go with a different name):

    user_movies
      user_id
      movie_id
    

    To know who watched a movie called Spaceballs, you need a query like this:

    SELECT u.name FROM user u 
      JOIN user_movies um ON um.user_id = u.id 
      JOIN movie m ON um.movie_id = m.id
        WHERE m.title = 'Spaceballs'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a one to many table with ids and traits for those users.
I have two tables users registered_members I want to confirm values from user table
I have a users table, the user ID is public. But I want to
I've got the following User model: class User < ActiveRecord::Base # Users table has
new to cakePHP and trying my first join. I've got one table called users
I've got a User table with a bitmask that contains the user's roles. The
i got a page users downloading files from there.And when a user click download
My database have got 4 table : users id username images id user_id image
I've got 2 tables that I need to get data from...my users table looks
I have 2 tables - an Account table and a Users table. Each account

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.