Follow us on Social Media:

MySQL Database Administrator

Boost Your Quick Knowledge in MySQL DBA Work, Concepts, Tips and Trick

Thursday, 19 April 2018

How to generate auto increment serial number column in MySQL Select Query / How to declear & pass variable in Select Query

In MySQL , We can generate auto increment serial number column during select query .

For e.g,

We have following table...

Using below queries , we can achieve the subjected discussion.

​SELECT @a:=@a+1 sr_num ,id,name,marks,insert_time from (select @a:=0) initvars, test.test;

Select all column :

SELECT @a:=@a+1 Sr_Num , A.* FROM (SELECT @A:= 0) initvars, test.test A ;

No comments:

Please Like and Subscribe us ....

Please visit the website on daily basis , Your New articles will publish at any moment. Please Subscribe us for getting Latest Updates...