Thanks to Rolando, his answer works fine. I also created a stored procedure to get that information, i'll post it if it's useful for somebody:
DROP PROCEDURE IF EXISTS mysql.getRowCount;
DELIMITER //
CREATE PROCEDURE mysql.getRowCount(DBNAME VARCHAR(30))
BEGIN
DECLARE NO_DATA int default 0;
DECLARE TBNAME varchar(30);
DECLARE TBS CURSOR FOR select table_name from information_schema.tables where table_schema=DBNAME;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET NO_DATA=1;
OPEN TBS;
CREATE TEMPORARY TABLE IF NOT EXISTS table_count (table_schema varchar(30),table_name varchar(30),table_count varchar(11)) ENGINE=MEMORY;
tbs:LOOP
FETCH TBS into TBNAME;
IF NO_DATA=1 THEN
LEAVE tbs;
END IF;
SET @query=concat('SELECT count(*) into @CONT from ',DBNAME,'.',TBNAME,';');
PREPARE test FROM @query;
EXECUTE test;
DEALLOCATE PREPARE test;
SET @query=concat('INSERT into table_count values ("',DBNAME,'","',TBNAME,'","',@CONT,'");');
PREPARE test FROM @query;
EXECUTE test;
DEALLOCATE PREPARE test;
END LOOP tbs;
CLOSE TBS;
SELECT * from table_count;
DROP TABLE table_count;
END//
DELIMITER ;
call mysql.getRowCount('mysql');
table
? Can you prefix it with the schema name so that you know where the data is coming from?select table_name,table_rows from information_schema.tables where table_schema='crmadmin' and table_name='table1';
and when i doselect count(*) from crmadmin.table1;
i get different results