Problem Statement: Make following query in Django API.
Table : Product
Fields:
id int primary_key
class_id int
class_content CharField
Each class_id have multiple class content.
For two different class id there are same as well as different class_content.
I want to list the difference between two class_id:
Here is how I can create query in raw SQL:
eg: generate difference between class_id = 1 and class_id =2
Query:
SELECT * FROM Product
WHERE class_id = 1 && class_content NOT IN
(SELECT class_content FROM Product WHERE class_id = 2);
This query works fine and gives the difference between class_id 1 and 2.
I want this query to be executed in django, I couldn’t draw same result from django APIs.
This should work: