开发者

Help with inner join query

开发者 https://www.devze.com 2023-03-29 13:41 出处:网络
I have two queries $query1=\"SELECT staffid, COUNT(staffid) FROM enrll GROUP BY staffid ORDER BY COUNT(staffid) DESC\";

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
0

精彩评论

暂无评论...
验证码 换一张
取 消