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
select @rownum:=@rownum+1 'autoID',m.mediaThumbnailUrl , q.surveyID from (SELECT @rownum:=0) r, media m join question q on m.mediaAutoID = q.backgroundImageID ;
You can USE the "UIID()" function that will provide you with an unique (alphanumerical) identified.
Check this out: https://stackoverflow.com/a/45963661/6083044
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
You can simulate it with something like this in your SELECT:
SELECT @rownum:=@rownum+1 AS rownum, dummy.*
FROM (SELECT @rownum:=0) r, dummy;