这是我的查询。
SELECT SQL_CALC_FOUND_ROWS (FOUND_ROWS() ) as total,
(SELECT GROUP_CONCAT(sp.specialization) FROM DSpecialization_Master dsp LEFT JOIN Specialization_Master sp on sp.id = dsp.specialization
WHERE dsp.profileid = pm.id and
(dsp.specialization = (select id from Specialization_master where specialization='Dentist' ))) as drspec ,
pm.id as profileid, pm.loginid as loginid, dam.clinicname, dam.area, dam.address, dam.pincode, dam.id as
addressid, dam.feecharge as feecharge, pm.fname, pm.lname, pm.email, pm.mobile, pm.phone, pm.gender, pm.dob,
pm.totexp, pm.imagepath, pm.languages, pm.statement, pm.createdby, um.profile_url, um.clinic_url,
pm.hsbit, (SELECT GROUP_CONCAT(education) FROM DEducation_Master WHERE profileid = pm.id ) as dredu
FROM Profile_Master pm LEFT JOIN DAddress_Master dam on dam.profileid = pm.id left join Unique_Url_Master um on
um.clinicid =dam.id WHERE dam.city='Surat' and pm.id IN (SELECT profileid FROM DSpecialization_Master
WHERE specialization = (select id from Specialization_master where specialization='Dentist')) ORDER BY pm.id limit 0 , 10
接受的结果是total:344
,我得到了total:1
。
我已经执行了这个查询,我得到了正确的结果。
select SQL_CALC_FOUND_ROWS id,(FOUND_ROWS() ) as total from unique_url_master1 limit 10;
total:1313
我在做什么错?仅供参考,我不能中断查询,即首先执行
选择 SQL_CALC_FOUND_ROWS
并执行
选择 FOUND_ROWS()
非常需要帮助..
编辑
我已更改查询并使用 count(*) 函数。现在我得到了正确的总数:344,但它只返回一行。现在有人可以指导我吗?
SELECT count(*) as total_count ,
(SELECT GROUP_CONCAT(sp.specialization) FROM DSpecialization_Master dsp LEFT JOIN Specialization_Master sp on sp.id = dsp.specialization WHERE dsp.profileid = pm.id and (dsp.specialization = (select id from Specialization_master where specialization='Dentist' ))) as drspec,
pm.id as profileid,
pm.loginid as loginid,
dam.clinicname,
dam.area,
dam.address,
dam.pincode,
dam.id as addressid,
dam.feecharge as feecharge,
pm.fname,
pm.lname,
pm.email,
pm.mobile,
pm.phone,
pm.gender,
pm.dob,
pm.totexp,
pm.imagepath,
pm.languages,
pm.statement,
pm.createdby,
um.profile_url,
um.clinic_url,
pm.hsbit,
(SELECT GROUP_CONCAT(education) FROM DEducation_Master WHERE profileid = pm.id ) as dredu
FROM Profile_Master pm
LEFT JOIN DAddress_Master dam on dam.profileid = pm.id
LEFT JOIN Unique_Url_Master um on um.clinicid =dam.id
WHERE dam.city='Surat'
AND pm.id IN (SELECT profileid FROM DSpecialization_Master WHERE specialization = (select id from Specialization_master where specialization='Dentist'))
ORDER BY pm.id
LIMIT 0, 10;
我已经在 MSSQL 中使用 COUNT(*) OVER() 进行查询,由于需求更改,我必须将 MSSQL 查询转换为 MYSQl。结果我这样接受