Tuesday, June 14, 2011

Add row number to MySQL table on select

Add row number to MySQL table on select.

Use the below query to get row number of table.


select row, host from (SELECT (@row := @row + 1) row, c.* FROM `columns_priv` c, (select @row := 0) c) as defined limit 10;

adding row number to MySQL table.
getting row numbers from non primary key table.
Adding row number column to the table in MySQL.