MySQL數(shù)據(jù)庫返回影響行數(shù)的實際操作流程
以下的文章主要是向大家描述的是MySQL數(shù)據(jù)庫返回影響行數(shù)的實際操作流程,我們主要是以介紹MySQL數(shù)據(jù)庫返回影響行數(shù)的時機(jī)應(yīng)用代碼來引出其具體的操作步驟,下面就是文章的主要內(nèi)容描述。
- found_rows() : select
- row_count() : update delete insert
注:需要配合相應(yīng)的操作一起使用,否則返回的值只是1和-1(都是不正確的值)
示例:
- drop database if exists `mytest`;
create database `mytest`;use `mytest`;
drop table if exists `MyTestTable`;
create table `MyTestTable`(`ID` int ,`Name` varchar(10));
insert into `MyTestTable`(`ID`,`Name`) select '1','role1'
union all select '2','role2' union all select '3','role3';select row_count();
輸出3(返回新添加的記錄數(shù)),[注:如果使用insert into...values只返回1]
- select * from `MyTestTable`;select found_rows();
輸出3(返回選擇的行數(shù))
- update `MyTestTable` set `Name`='people';select row_count();
輸出3(返回修改的行數(shù))
- delete from `MyTestTable`;select row_count();
輸出3(返回刪除的行數(shù)),以上的相關(guān)內(nèi)容就是對MySQL數(shù)據(jù)庫返回影響行數(shù)的代碼介紹,望你能有所收獲。
上述的相關(guān)內(nèi)容就是對MySQL數(shù)據(jù)庫返回影響行數(shù)的代碼的描述,希望會給你帶來一些幫助在此方面。
【編輯推薦】