Does Mysql have an equivalent to @@ROWCOUNT like in mssql?

后端 未结 5 1598
情深已故
情深已故 2020-11-27 05:05

How can I get row count values in MySQL as @@ROWCOUNT does in mssql?

5条回答
  •  囚心锁ツ
    2020-11-27 05:45

    There is another way:

    CREATE TEMPORARY TABLE `results` AS ( *** Your query without LIMIT *** );
    

    Get the row count

    SELECT COUNT(*) FROM `results`;
    

    Get your subset

    SELECT * FROM `results` LIMIT 5,10;
    

    The temporary table exists only in the current session. I would still clean-up afterwards

    DROP TEMPORARY TABLE `results`;
    

提交回复
热议问题