日期:2014-05-16  浏览次数:20774 次

用什么语句可以获知数据库数据的更新?
在mysql下获取数据,想用标志位的方法,用一个函数获取数据库的最新信息,当有更新时,读取数据。
应该用什么语句来获知啊。
mysql_affected_rows()语句可以吗,返回最新的UPDATE, DELETE或INSERT查询影响的行数。
不会用纠结,求前辈们指导!

------解决方案--------------------
ROW_COUNT() 可以得到
------解决方案--------------------
update ...;
select ROW_COUNT();
------解决方案--------------------
引用ROW_COUNT()

ROW_COUNT() returns the number of rows updated, inserted, or deleted by the preceding statement. This is the same as the row count that the mysql client displays and the value from the mysql_affected_rows() C API function.

mysql> INSERT INTO t VALUES(1),(2),(3);
Query OK, 3 rows affected (0.00 sec)
Records: 3 Duplicates: 0 Warnings: 0

mysql> SELECT ROW_COUNT();
+-------------+
| ROW_COUNT() |
+-------------+
| 3 |
+-------------+
1 row in set (0.00 sec)

mysql> DELETE FROM t WHERE i IN(1,2);
Query OK, 2 rows affected (0.00 sec)

mysql> SELECT ROW_COUNT();
+-------------+
| ROW_COUNT() |
+-------------+
| 2 |
+-------------+
1 row in set (0.00 sec)


------解决方案--------------------
探讨

用MySQL Administrator在MySQL查询浏览器里ROW_COUNT()一直显示-1
在命令行客户端就显示正常
不知道什么原因

------解决方案--------------------
探讨
我想知道怎么获取row_count的值,我用mysql_real_query都不能正常获取他的结果