In MySQL 3.23.44 and up会不会是你的mysql的版本问题
解决方案 »
- php图片路径处理—有图有真相
- 关于单元测试?
- phpexcel下载excel乱码问题
- 请问这段代码为什么不能控制
- Your browser (or proxy) sent a request that this server could not understand在线等急
- 比较天真的问题,大家来看看
- 100分求助:php开发百度文库在线展示office文档,并可在线复制文档内容
- 为什么没找到id
- 想实现每次访问后删除id的代码,谁能给我修正修正?
- 问个菜菜的问题,不是已经有HTMl了么,那还要php、asp、jsp做什么呢?
- *****iis6+php以CGI方式运行!发现错误~Why???*****
- Php+MSSQL 查询10万以上记录出现错误码:Fatal error: Maximum execution time of 30 seconds exceeded in
应该是你mysql的问题除非你执行SQL语句的时候顺序颠倒了
SELECT * FROM shirt;
+----+---------+--------+-------+
| id | style | color | owner |
+----+---------+--------+-------+
| 1 | polo | blue | 1 |
| 2 | dress | white | 1 |
| 3 | t-shirt | blue | 1 |
| 4 | dress | orange | 2 |
| 5 | polo | red | 2 |
| 6 | dress | blue | 2 |
| 7 | t-shirt | white | 2 |
+----+---------+--------+-------+,这结果是正确的,然后我用下面的php插入一条记录mysql_query("INSERT INTO shirt VALUES(NULL,'dress','orange',LAST_INSERT_ID())");,在这php执行后,我又转到DOS命令提示符下,在用INSERT INTO shirt VALUES(NULL,'dress','orange',LAST_INSERT_ID());语句执行了一下.结果现在SELECT * FROM shirt;
+----+---------+--------+-------+
| id | style | color | owner |
+----+---------+--------+-------+
| 1 | polo | blue | 1 |
| 2 | dress | white | 1 |
| 3 | t-shirt | blue | 1 |
| 4 | dress | orange | 2 |
| 5 | polo | red | 2 |
| 6 | dress | blue | 2 |
| 7 | t-shirt | white | 2 |
| 8 | dress | orange | 0 |
| 9 | dress | orange | 4 |
+----+---------+--------+-------+这owner的指怎么会为0或4呢.在person表的id中没有这两个值呀?
这是LAST_INSERT_ID()的问题
LAST_INSERT_ID()应该获取当前连接下的person最后一次insert的id所以会得到owner=0,至于owner=4我也搞不太清楚,你在当前连接下再插入一条也应该还是4,但是如果你断开连接,再重新连通mysql,owner就应该是8了,他好像取的是上一次连接id的第一次插入的shirt.id