用in做的子查询返回1200行的时候前面主句就会报错子查询不止一个,但返回1050行的时候是正常的。
SELECTtb_publicvoice.*, (
SELECT
did
FROM
tb_daily_pv
WHERE
tb_daily_pv.pvid = tb_publicvoice.id
) AS daily_id,
(
SELECT
(
SELECT
CAST (dispose_doc_no AS VARCHAR) + ','
FROM
tb_pv_dispose
WHERE
tb_pv_dispose.id
= tb_publicvoice.id
FOR xml path ('')
)
) AS dispose_doc_no,
(
SELECT
daily_id
FROM
tb_pv_feedback_daily
WHERE
tb_pv_feedback_daily.id
= tb_publicvoice.id
) AS feedback_daily_id,
(
SELECT
COUNT (*)
FROM
tb_pv_comment
WHERE
tb_pv_comment.id
= tb_publicvoice.id
) AS comment_count,
(
SELECT
content
FROM
tb_pv_feedback
WHERE
tb_pv_feedback.id
= tb_publicvoice.id
AND tb_pv_feedback.type = 0
) AS docFeedback,
(
SELECT
content
FROM
tb_pv_feedback
WHERE
tb_pv_feedback.id
= tb_publicvoice.id
AND tb_pv_feedback.type = 1
) AS webFeedback
FROM
tb_publicvoice
WHERE
tb_publicvoice.id
IN (
SELECT
pvid
FROM
tb_pv_notify
WHERE
tb_pv_notify.uid = 'admin'
)
AND tb_publicvoice.createtime < '2017-08-16'
AND tb_publicvoice.createtime > '2016-08-16'
ORDER BY
tb_publicvoice.createtime DESC