»Ë»Ñ Æ÷·³
°³¹ßÀÚÆ÷·³ ÀÔ´Ï´Ù.
  • ºÏ¸¶Å© ¾ÆÀÌÄÜ

MySQL ¹®ÀÚ¿­·Î ÀúÀåµÈ ±Û¹øÈ£¸¦ ºÒ·¯¿Í¼­ ÃÖ´ë°ª+1 ÇÑ »óÅ·Π´Ù½Ã ÀúÀåÇÏ°í ½Í½À´Ï´Ù.7

MySQL Áú¹®µå¸³´Ï´Ù.
¹®ÀÚ·Î ÀúÀåµÈ Ä÷³ µ¥ÀÌÅ͸¦ ¼ýÀÚ·Î ºÒ·¯¿Í¼­ ´Ù½Ã ¹®ÀÚ·Î ÀúÀåÇÏ°í ½Í½À´Ï´Ù.

notices Å×À̺í ÀÔ´Ï´Ù.
mysql> desc notices;
+---------+---------------+------+-----+-------------------+-----------------------------+
| Field | Type | Null | Key | Default | Extra |
+---------+---------------+------+-----+-------------------+-----------------------------+
| seq | varchar(10) | NO | PRI | | |
| title | varchar(200) | YES | | NULL | |
| writer | varchar(50) | YES | | NULL | |
| content | varchar(4000) | YES | | NULL | |
| regdate | timestamp | NO | | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP |
| hit | int(11) | YES | | NULL | |
+---------+---------------+------+-----+-------------------+-----------------------------+
6 rows in set (0.00 sec)

¿©±â¿¡ insert ¹®À¸·Î »ðÀÔÇÏ·Á°í Çß´õ´Ï ¿¡·¯°¡ ³³´Ï´Ù.
mysql> insert into notices(seq, title, content, writer, regdate, hit)
-> values((select max(cast(seq as signed)+1) from notices), '¹®ÀÚ1', '¹®ÀÚ2', 'newlec', now(), 0);
ERROR 1093 (HY000): You can't specify target table 'notices' for update in FROM clause

ÇÏÁö¸¸ select¹®¸¸ µû·Î ¶¼¾î¼­ ½ÇÇà½ÃÄѺ¸¸é ½ÇÇàÀÌ µË´Ï´Ù.
mysql> select max(cast(seq as signed)+1) from notices;
+----------------------------+
| max(cast(seq as signed)+1) |
+----------------------------+
| 5 |
+----------------------------+
1 row in set (0.00 sec)

Å×ÀÌºí ¸íÀ» ¸øã´Â´Ù´Âµ¥ ¿Ö ¸øã´ÂÁö ±Ã±ÝÇÕ´Ï´Ù. 
¾Æ ¿µ¾îµµ ¸øÇÏ°í Âü ¾î·Æ³×¿ä

0
ÃßõÇϱ⠴ٸ¥ÀÇ°ß 0
|
°øÀ¯¹öÆ°

´Ù¸¥ÀÇ°ß 0 Ãßõ 0 À̰žȸÔÈ÷³×

´Ù¸¥ÀÇ°ß 0 Ãßõ 0 ȸÃá±ã½º

´Ù¸¥ÀÇ°ß 0 Ãßõ 0 [* ºñȸ¿ø *]

´Ù¸¥ÀÇ°ß 0 Ãßõ 0 ȸÃá±ã½º

´Ù¸¥ÀÇ°ß 0 Ãßõ 1 windwishers

´Ù¸¥ÀÇ°ß 0 Ãßõ 0 ȸÃá±ã½º

´Ù¸¥ÀÇ°ß 0 Ãßõ 0 SSH
  • ¾Ë¸² ¿å¼³, »óó ÁÙ ¼ö ÀÖ´Â ¾ÇÇÃÀº »ï°¡ÁÖ¼¼¿ä.
©¹æ »çÁø  
¡â ÀÌÀü±Û¡ä ´ÙÀ½±Û ¸ñ·Ïº¸±â