0

I have a query[1] in MySQL which im using to derive an answer for the question (Movies in which acted has acted) .I am getting the correct rowset in MySQL.

I now want to know how can I convert query[1] into a Django query :: the query is as follow::

SELECT movie_name 
  FROM movies_movie 
 WHERE movie_id 
    IN ( SELECT movie_id 
           FROM movies_crew 
          WHERE Crew_name_id 
             IN ( SELECT crew_id 
                    FROM movies_crewname 
                   WHERE name 
                    LIKE %shaun%));

NOTE::

  • The movie_id is the PK of movies table

  • movies_crew contains crew_name_id (referenced from movies_crewname) and movie_id (referenced from movies)

  • movies_crewname contains crew_id as PK

Can someone please show me the right way to write Django query?

1 Answer 1

2
Movie.objects.filter(crew__crewname__name__icontains="shaun")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.