code_junkie

MySQL SELECT LAST_INSERT_ID() for compound key. Is it possible?

Nov 13th, 2011
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.23 KB | None | 0 0
  1. CREATE TABLE foo (
  2. id1 int(11) NOT NULL auto_increment,
  3. id2 int(11) NOT NULL default '0',
  4. PRIMARY KEY (id1, id2)
  5. );
  6.  
  7. INSERT INTO foo VALUES (DEFAULT, 2);
  8.  
  9. SELECT LAST_INSERT_ID(); -- returns 1, the value generated for id1
Add Comment
Please, Sign In to add comment