您的位置:首页 > 其它

取最后一条插入的数据

2008-11-17 10:17 176 查看
a2/hl(X) 10:09:14
排序后取最后一条啊
a2/hl(X) 10:09:39
你的id是递增的还是随机

a1Xxx10:10:08
递增

a2/hl(X) 10:09:14
排序后取最后一条啊
a2/hl(X) 10:10:30
那就select max(id) from table

a3(Xx) 10:11:00
@@identity
a3(Xx) 10:11:50
直接写在插入语句的后面 插入后返回值就是了
a1Xxx10:12:37
石头,怎么返回?

a3(Xx) 10:13:05
insert ....;@@identity
a3(Xx) 10:13:11
这样写

a3(Xx) 10:13:52
返回的就是id
a1Xxx10:14:52
好,我试试,谢谢
a2/hl(X) 10:15:43
这种返回你最好一次插入一条
a2/hl(X) 10:15:57
多条返回多个值
a1Xxx10:16:14
恩,我每次插入的是一条
a2/hl(X) 10:16:48
那就这样也可以

 

 

a1Xxx10:21:54
insert into depot(depotname,telephone,address,remarks,acquiescence) values(?,?,?,?,?);@@identity
a3(Xx) 10:22:05

a1Xxx10:22:08
语法错了吗?
a1Xxx10:22:24
我这里报错了。说语法有错
a3(Xx) 10:25:48
select @@identity
a3(Xx) 10:26:02
不好意思漏了个关键字
a3(Xx) 10:26:12
前面加上select
a1Xxx10:26:37
恩,谢谢
a1Xxx10:26:39
可以了

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  insert