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:-
CREATE VIEW pending_assign_report_view AS
select cg.group_name,c.client_name, wt.work_type,p.Minor_worktype, ay.year,aev.emp_name,ep.Date_assigned_on
from employee_project ep,active_employee_view aev, project p, client_group cg, client c,work_type wt,assessment_year ay
where ep.task_status_id=1 and ep.username=aev.username and ep.project_id=p.project_id and p.Year_id=ay.Year_id
and p.Client_group_id=cg.client_group_id and p.Client_id=c.Client_id and p.Work_type_id=wt.Work_type_id
order by cg.group_name,c.client_name, aev.emp_name;
Now I want Id column as first column which should be auto_increment in nature. How should I do this? Thanks in advance.
You can simulate it with something like this in your SELECT:
SELECT @rownum:=@rownum+1 AS rownum, dummy.*
FROM (SELECT @rownum:=0) r, dummy;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With