union all 以后如何整体排序limit限制条数

       SELECT * as total FROM (
                (SELECT live_msg.id AS oid from stat_user_liver_refer_stock,live_msg            
                WHERE  l_id not in ($liveLids) 
                and  live_msg.rec_time>DATE_SUB(NOW(), INTERVAL 48 HOUR)
                AND  kind <> 'vip' 
                and  live_msg.state in ('','del_own') 
                and  live_msg.only_self_show = 'no' 
                and  live_msg.is_discuss_show_talk = 1
                and live_msg.price in ('0','0-0')
                and  object_code='$theme_id'
                and object_kind=2 and opinion_kind=1
                and live_msg.id=origin_id and live_msg.u_id >0 
                 )           
                UNION ALL       
                (SELECT user_msg.id AS oid from stat_user_liver_refer_stock,user_msg     
                WHERE  user_msg.rec_time> DATE_SUB(NOW(), INTERVAL 48 HOUR)
                AND user_msg.state = ''
                and user_msg.only_self_show = 'no'
                and user_msg.is_discuss_show_talk =1
                and object_code='$theme_id' 
                and object_kind=2 
                and opinion_kind=2 
                and user_msg.id=origin_id )
            ) AS a order by id desc limit 20
    
posted @ 2021-12-30 16:15  17601621550  阅读(423)  评论(0编辑  收藏  举报