Dynamic result in select statement mysql I want to get max value as maxvalue column of a column, table returned by the following query.

IE: if the following query returns table name test_tab and column name as
test_col then the following query should return max value of the table test_tab and column  test_col .

which would give me the maximum value of auto incremented columns in my database with table name and column name.

SELECT c.table_name,c.column_name ,'' maxvalue
FROM INFORMATION_SCHEMA.COLUMNS c
WHERE  EXTRA = 'auto_increment'
I could not understand your requirement. Hope it works :

select t.table_schema,t.table_name,t.AUTO_INCREMENT 
from information_schema.TABLES t,information_schema.COLUMNS c
where c.EXTRA = 'auto_increment' and t.table_schema=c.table_schema and t.table_name=c.table_name