[英]Help with inner join query
我有兩個疑問
$query1="SELECT staffid, COUNT(staffid) FROM enrll GROUP BY staffid ORDER BY COUNT(staffid) DESC";
$query2="SELECT staffid FROM staff as s WHERE auth = '1' AND NOT EXISTS ( SELECT staffid from shdl as h where s.staffid=h.staffid and h.shdldt='".$unixdt."')";
這兩個查詢都返回數組中的值,我想從query1中找出那些具有與query2的內部連接的人員,而值將在數組中。
注意兩個查詢的組合查詢將返回最終查詢。
select e.staffid, count(e.staffid)
from enrll e
join staff s on e.staffid=s.staffid
where s.auth = '1' and NOT EXISTS (
SELECT staffid from shdl as h
where s.staffid=h.staffid and h.shdldt='$unixdt')
group by e.staffid
ORDER BY COUNT(staffid) DESC
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.