Is it possible to create auto increment id column in mysql view?

后端 未结 4 1716
南笙
南笙 2021-01-18 10:04

I have created a view in MySql. But now my requirement is to create an Id column in that view which should be auto increment.

My current view is:-

CR         


        
相关标签:
4条回答
  • 2021-01-18 10:40

    select @rownum:=@rownum+1 'autoID',m.mediaThumbnailUrl , q.surveyID from (SELECT @rownum:=0) r, media m join question q on m.mediaAutoID = q.backgroundImageID ;

    0 讨论(0)
  • 2021-01-18 10:42

    You can USE the "UIID()" function that will provide you with an unique (alphanumerical) identified.

    Check this out: https://stackoverflow.com/a/45963661/6083044

    0 讨论(0)
  • 2021-01-18 10:48

    View in database is a mirror copy of our some data from our database. In real it does not exist. It have same structure as of main table

    So its structure can not change

    0 讨论(0)
  • 2021-01-18 10:51

    You can simulate it with something like this in your SELECT:

    SELECT @rownum:=@rownum+1 AS rownum, dummy.*
    FROM (SELECT @rownum:=0) r, dummy;
    
    0 讨论(0)
提交回复
热议问题