Creating MySQL View using UNION

后端 未结 5 1825
逝去的感伤
逝去的感伤 2021-02-14 06:18

I am trying to create a view for the following query.

SELECT DISTINCT
  products.pid        AS id,
  products.pname      AS name,
  products.p_desc     AS descri         


        
5条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-14 06:49

    Just a little remark about UNION. UNION only returns the distinct values of your resultset. So there is no need to use SELECT DISTINCT combined with a UNION. Probably better for performance to not use DISTINCT too.

    More info on UNION can be found here: SQL UNION Operator

提交回复
热议问题