Home > Database > Mysql Tutorial > MySQL返回影响行数的测试示例

MySQL返回影响行数的测试示例

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 16:20:50
Original
1256 people have browsed it

found_rows() : select row_count() : update delete insert 注:需要配合相应的操作一起使用,否则返回的值只是1和-1(都是不正确的值) 示例: drop database if exists `mytest`; create database `mytest`; use `mytest`; drop table if exists `MyTestTable

   found_rows() : select

  row_count() : update delete insert

  注:需要配合相应的操作一起使用,否则返回的值只是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(返回新添加的记录数),[注:如果使用insert into...values只返回1]

  select * from `MyTestTable`;select found_rows(); -- 输出3(返回选择的行数)

  update `MyTestTable` set `Name`='people';select row_count(); -- 输出3(返回修改的行数)

  delete from `MyTestTable`;select row_count(); -- 输出3(返回删除的行数)

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
MySQL stops process
From 1970-01-01 08:00:00
0
0
0
Error when installing mysql on linux
From 1970-01-01 08:00:00
0
0
0
phpstudy cannot start mysql?
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template