mysql + show tables and insert a row number for each table -
this command shows tables.
mysql> show tables '%xyz%'; +------------------------------+ | tables_in_xyz (%xyz%) | +------------------------------+ | xyz2 | | xyz23 | | xyz23_linuxlineending | +------------------------------+ 3 rows in set (0.00 sec)
what command there insert index number each table e.g.
+----+------------------------------+ | id | tables_in_xyz (%xyz%) | +----+------------------------------+ | 1 | xyz2 | | 2 | xyz23 | | 3 | xyz23_linuxlineending | +----+------------------------------+
edit1 - close
mysql> select (@rn := @rn + 1) id, table_name information_schema.tables table_name '%xyz%'; +------+-----------------------+ | id | table_name | +------+-----------------------+ | null | xyz2 | | null | xyz23 | | null | xyz23_linuxlineending | +------+-----------------------+ 3 rows in set (0.00 sec)
edit2 - want
mysql> set @rn :=0; query ok, 0 rows affected (0.00 sec) mysql> select (@rn := @rn + 1) id, table_name information_schema.tables table_name '%xyz%'; +------+-----------------------+ | id | table_name | +------+-----------------------+ | 1 | xyz2 | | 2 | xyz23 | | 3 | xyz23_linuxlineending | +------+-----------------------+ 3 rows in set (0.00 sec)
you use information_schema.tables
:
select (@rn := @rn + 1) id, table_name information_schema.tables cross join (select @rn := 0) params table_name '%xyz%';