我有3张桌子。
Table ='FileName', Field inside FileName = 'ID'
儿童表'部门A'与' FileName' ID'相关,Department A = 'LastNameA'
内的字段
儿童表'部门B'与' FileName'相关通过' ID',Department B = 'LastNameB'
是否可以选择所有ID'来自' FileName'的记录表WHERE'Department A::LastNameA' = 'Department B::LastNameB'
?
如果是这样,我该怎么写这个陈述?
答案 0 :(得分:0)
问题有点不清楚哪个字段在哪个表中,但选择哪个版本适合您。
SELECT ID
FROM FileName fn
INNER JOIN DepartmentA da ON fn.ID = da.LastNameA
INNER JOIN DepartmentB db ON fn.ID = db.LastNameB
WHERE da.LastNameA = db.LastNameB
或者
SELECT ID
FROM FileName fn
INNER JOIN DepartmentA da ON fn.ID = da.ID
INNER JOIN DepartmentB db ON fn.ID = db.ID
WHERE da.LastNameA = db.LastNameB