Creating MySQL View using UNION

后端 未结 5 1843
逝去的感伤
逝去的感伤 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:25

    You have different types being unioned into the same column. (The names can be different, but the types have to be the same, or at least auto-castable.) But as @Learning points out, it looks like you've twisted the SELECT column enumerations.

    Just in case, the proper syntax (which worked for me) is

    CREATE VIEW myView 
    AS  
    SELECT ... 
    

提交回复
热议问题