SQL查询
select *
from products_product
left join (
select *
from products_purchase
join products_product on products_purchase.product_id = products_product.name
where user_id = 1
) t on t.name = products_product.name
where products_product.name like '03%';
我想在Django orm上编写此查询,并使用user_id Null检查是否存在行。