mysql中()上的计数(*)替换
这是我的SQL server查询mysql中()上的计数(*)替换,mysql,sql-server,Mysql,Sql Server,这是我的SQL server查询 ` Select top 8 count(id) OVER () as speccount, (SELECT count(*) From Profile_Master pm WHERE CONCAT(pm.fname , pm.lname) LIKE '%'+@keyword+'%' and (select Top 1 city from DAddress_Master where profileid=pm.id)=@city) as drcount, (SEL
` Select top 8
count(id) OVER () as speccount,
(SELECT count(*) From Profile_Master pm WHERE CONCAT(pm.fname , pm.lname) LIKE '%'+@keyword+'%' and
(select Top 1 city from DAddress_Master where profileid=pm.id)=@city) as drcount,
(SELECT count(*) From DAddress_Master dam WHERE dam.city=@city and dam.clinicname LIKE '%'+@keyword+'%') as cliniccount,
specialization AS name,
id as id,
'Specialization' as type,
'' as drspec
From Specialization_Master
Where specialization LIKE '%'+@keyword+'%'`
实际上是我整个问题的一部分。现在我必须将这个查询转换成mysql,这没什么大不了的,但是有人能告诉我mysql中的count(*)OVER()的替代品吗
我偶然发现了这一点
选择SQL\u CALC\u FOUND\u ROWS
并选择“查找”行()
但是还有其他方法吗?最简单的方法可能是子查询:
select (select count(*) from Specialization where specialization LIKE '%'+@keyword+'%'`
) as speccnt
注意:如果您正在切换数据库,并且使用的是窗口函数等功能,您可能会考虑PigGrES,而不是MySQL,因为PoxGrES支持窗口函数。
最简单的方法可能是子查询:
select (select count(*) from Specialization where specialization LIKE '%'+@keyword+'%'`
) as speccnt
注意:如果您正在切换数据库,并且使用诸如窗口函数之类的功能,则可以考虑PigGrES,而不考虑MySQL,因为PistGRE支持窗口函数。