怎么取得update了record的primary key id

如何取得update了record的primary key id?updatetestsetsex Mwherename johntable:idnamesex1johnF2mayM

如何取得update了record的primary key id?
update   test   set   sex= 'M '   where   name= 'john '

table:
id   name   sex
1     john   F
2     may     M
如何知道john这个record的id?谢谢

[解决办法]
select last_insert_id();