in语句执行很慢,改成exists下边的语句该怎么写
select * from 企业 as com where Id IN (SELECT 企业 FROM GB_CompTitles WHERE (SELECT AVG(用户评级) FROM GB_CompTitles WHERE 企业 = com.id) = " + kehu + ")
优化成 exists 具体该怎么写?
------解决方案--------------------
SQL code
SELECT A.*
FROM 企业 A
JOIN (SELECT 企业,AVG(用户评级) AS CLASS FROM GB_CompTitles GROUP BY 企业) B
ON B.企业 = A.id
WHERE B.CLASS=@kehu