I have two queries
$query1="SELECT staffid, COUNT(staffid) FROM enrll GROUP BY staffid ORDER BY COUNT(staffid) DESC";
$query2="SELE开发者_如何学JAVACT 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."')";
Both queries are returning values in array, I want to find out those staffid from query1 having inner join with query2 and values would be in array.
NOTE What would be combined query for both query to return final query.
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
精彩评论