這是我的查詢的一部分,我在此查詢之前有一個聯合。我想在條件下選擇table1中的更多列。內部加入並選擇該表上的其他列
SELECT c.ID, c.Name, c.Position, c.Email, c.ContactNumber
FROM table1 c
INNER JOIN table2 a
ON c.ID = (SELECT foreignID FROM table2 WHERE a.Name = 'someName')
WHERE Dept = 'Something' --this will return nothing since in the inner join
--the condition returns a single column and it doesn't
--satisfy the WHERE Clause
我要選擇滿足ID(工作)的人,包括東西的部門人。有解決這個問題的另一種方法,或者我真的需要使用UNION來做到這一點。這會影響應用程序,特別是移動應用程序的性能嗎?
部門是該表中的列?你不能只使用'ON c.ID = a.foreignID和Dept = Something'? –
Dept來自表1 –