我想知道如何寫在Django查詢的連接條件下面的SQL查詢條件:如何寫加入Django的查詢
SELECT
s.name,
l.name,
a.name,
a.asset_code,
c.name,
ad.name,
a.model_no,
a.serial_no
FROM
asset_mgmt_asset_assignment_employee ae,
asset_mgmt_asset a,
asset_mgmt_department ad,
asset_mgmt_employee e,
asset_mgmt_sublocation s,
asset_mgmt_location l,
asset_mgmt_asset_category c
WHERE
ae.asset_id = a.id AND
ae.department_id = ad.id AND
ae.employee_id = e.id AND
ad.location_id = l.id AND
l.Sublocation_id = s.id AND
c.id = a.asset_category_id AND
s.id = 2;
我們如何在Django查詢混合所有這些表?
由該查詢返回的元組並不像您的任何表。 ORM如何將這些元組映射到對象中? – Kevin