开发者

Make my own incrementing mysql id without auto increment

How can I duplicate the function of an auto incrementing Id field without ma开发者_开发问答king the field itself auto incrementing? I suppose on my INSERT statement, I would need to somehow grab the last id created, and add +1 on the new entry. But I don't know how. Any help is appreciated.

EDIT: I ended up taking ypercube's advice and keeping the id field as autoincrementing and making my searchstring unique. Thanks!


You'd need to select the highest current ID in one query, then use that when inserting using a second query.

To get round the race conditions, you could create a table lock (nasty) or use transactions (better, but not ideal)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜