åé¡ MySQLã«ã·ã¼ã±ã³ã¹ããï¼ çã åçã®ãã¨ã¯ã§ãããã§ãæå¤ã¨æ£ãã使ã£ã¦ããããªããã¨ãããã å ¬å¼ããã¥ã¡ã³ãã§ãç´¹ä»ãã¦ããã·ã¼ã±ã³ã¹ã®ã¨ãã¥ã¬ã¼ãæ¹æ³ã®ã¡ã¢ã ï¼ãã·ã¼ã±ã³ã¹ç¨ã®ãã¼ãã«ãä½ã æ°å¤ãå ¥ããã«ã©ã ãããã1è¡ã ãã¬ã³ã¼ããããã°ãããAUTO_INCREMENTããå¿ è¦ã¯ãªãã mysql> CREATE TABLE sequence (id INT NOT NULL); mysql> INSERT INTO sequence VALUES (0); ï¼ãã·ã¼ã±ã³ã¹çªå·ãåå¾ãã ãã£ãã使ããã mysql> UPDATE sequence SET id=LAST_INSERT_ID(id+1); mysql> SELECT LAST_INSERT_ID(); UPDATEæã§ã·ã¼ã±ã³ã¹ã®çªå·ãå¢ããã¦ãLAST_INSERT_ID()ã¸ã¯+1ããçªå·ã
{{#tags}}- {{label}}
{{/tags}}