插入新行时,自动增量auto-increment
会获取该行的新值(前一个+ 1)。在更新的情况下如何将mysql制作成id
?
假设,最后插入的行的id = 10.如果我插入一行,则11
将为12
。如何将第7行的id更新为12
如果我抛出更新命令?
我尝试了以下更新了id = auto_increment
,但11
仍然留给Duplicate key '11' Exception
,并且在更新命令后导致update `users` set id = LAST_INSERT_ID()+1 where cid = "c1" and uid = "p1"
插入跑了。
updates
即使对于insert .. on duplicate key update
或 self.view.addSubview(courseView!)
let aspectConstraint = NSLayoutConstraint(item: courseView,
attribute: .Height,
relatedBy: .Equal,
toItem: courseView,
attribute: .Width,
multiplier: courseView.frame.size.height / courseView.frame.size.width,
constant: 0.0)
aspectConstraint.active = true
let topConstraint = courseView.topAnchor.constraintGreaterThanOrEqualToAnchor(topLayoutGuide.bottomAnchor, constant: 15)
topConstraint.active = true
let leadingConstraint = courseView.leadingAnchor.constraintLessThanOrEqualToAnchor(view.leadingAnchor, constant: 15)
leadingConstraint.active = true
let trailingConstraint = courseView.trailingAnchor.constraintGreaterThanOrEqualToAnchor(view.trailingAnchor, constant: -15)
trailingConstraint.active = true
let bottomConstraint = courseView.bottomAnchor.constraintLessThanOrEqualToAnchor(view.bottomAnchor, constant: -15)
bottomConstraint.active = true
,我怎样才能使自动递增增加?