| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2050 人关注过本帖
标题:用in做的子查询返回1200行的时候前面主句就会报错子查询不止一个,但返回10 ...
取消只看楼主 加入收藏
su13800
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2017-8-16
结帖率:0
收藏
已结贴  问题点数:20 回复次数:1 
用in做的子查询返回1200行的时候前面主句就会报错子查询不止一个,但返回1050行的时候是正常的。
SELECT
    tb_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
搜索更多相关主题的帖子: 子查询 返回 SELECT FROM WHERE 
2017-08-16 10:11
su13800
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2017-8-16
收藏
得分:0 
大神在哪里出来指教下。
2017-08-16 10:13
快速回复:用in做的子查询返回1200行的时候前面主句就会报错子查询不止一个,但返 ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.034074 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved