美文网首页
mysql UNION

mysql UNION

作者: answer6 | 来源:发表于2018-09-29 21:50 被阅读0次

    一样的联表查询,不一样的条件筛选,最后把数据整合到一起 UNION

    select pro_parent as product_id from tb1
    where pro_type = 'variation' group by pro_parent
    
    UNION
    
    select product_id as id from tb1 where pro_type = 'simple'
    

    end 记录下先


    • 补充下 mysql union
    - select * from A union all select * from B  //A B数据结构一定要一样
    

    union 之后再做处理的话需要

    (SELECT uid,umobile,realname FROM users WHERE vip IN (8, 9))       
    UNION
    (SELECT uid,umobile,realname FROM users WHERE vip NOT IN (8, 9) AND amount > 0   )
     ORDER BY uid desc limit 10
    

    相关文章

      网友评论

          本文标题:mysql UNION

          本文链接:https://www.haomeiwen.com/subject/retioftx.html