mysql 内嵌sql 如何分页
发布网友
发布时间:2022-04-22 12:53
我来回答
共1个回答
热心网友
时间:2022-04-08 08:33
直接在最外层分页就好了
SELECT
COUNT(1) AS NO,
base_id,
ycpersonal_id,
yc_cert_id,
ouid,
udepartmentID,
de_name,
cert_level,
cert_level_name,
cert_profession,
cert_profession_name,
cert_binding,
cert_binding_name,
three_classes,
three_classes_name
FROM
(
SELECT
cb.id AS base_id,
ct.id AS ycpersonal_id,
ce.id AS yc_cert_id,
cb.ouid,
cb.udepartmentID,
de.name AS de_name,
ce.cert_level,
gc.name AS cert_level_name,
ce.cert_profession,
gp.name AS cert_profession_name,
ce.cert_binding,
gb.name AS cert_binding_name,
ct.three_classes,
ge.name AS three_classes_name
FROM
`my_conm_base` AS cb
LEFT JOIN my_conm_ycpersonnel AS ct
ON cb.id = ct.conmid
LEFT JOIN my_conm_ycpersonnel_cert AS ce
ON ce.personnelid = ct.id
LEFT JOIN my_category AS gc
ON gc.id = ce.cert_level
LEFT JOIN my_category AS gp
ON gp.id = ce.cert_profession
LEFT JOIN my_category AS gb
ON gb.id = ce.cert_binding
LEFT JOIN my_category AS ge
ON ge.id = ct.three_classes
LEFT JOIN my_department AS de
ON de.id = cb.udepartmentID
WHERE cb.state <> 18
AND cb.udepartmentid IN (10001)
AND cb.stype = 961
AND ce.id > 0
GROUP BY ce.personnelid
ORDER BY cb.id,
ce.cert_level DESC
) AS LIST
GROUP BY cert_level,
cert_profession,
cert_binding,
three_classes
ORDER BY cert_level limit 0,10