Mysql
 sql >> Teknologi Basis Data >  >> RDS >> Mysql

masukkan peningkatan otomatis ke kolom kedua

mysql> describe concattest;
+-------+------------------+------+-----+---------+----------------+
| Field | Type             | Null | Key | Default | Extra          |
+-------+------------------+------+-----+---------+----------------+
| id    | int(10) unsigned | NO   | PRI | NULL    | auto_increment |
| val   | text             | YES  |     | NULL    |                |
+-------+------------------+------+-----+---------+----------------+
2 rows in set (0.00 sec)

mysql> INSERT INTO concattest (val) VALUES (concat('val', LAST_INSERT_ID()));
Query OK, 1 row affected (0.06 sec)

mysql> select * from concattest;
+----+------+
| id | val  |
+----+------+
|  1 | val0 |
+----+------+
1 row in set (0.00 sec)

mysql> INSERT INTO concattest (val) VALUES (concat('val', LAST_INSERT_ID()));
Query OK, 1 row affected (0.00 sec)

mysql> select * from concattest;
+----+------+
| id | val  |
+----+------+
|  1 | val0 |
|  2 | val1 |
+----+------+
2 rows in set (0.00 sec)

mysql> INSERT INTO concattest (val) VALUES (concat('val', LAST_INSERT_ID()));
Query OK, 1 row affected (0.00 sec)

mysql> select * from concattest;
+----+------+
| id | val  |
+----+------+
|  1 | val0 |
|  2 | val1 |
|  3 | val2 |
+----+------+
3 rows in set (0.00 sec)



  1. Database
  2.   
  3. Mysql
  4.   
  5. Oracle
  6.   
  7. Sqlserver
  8.   
  9. PostgreSQL
  10.   
  11. Access
  12.   
  13. SQLite
  14.   
  15. MariaDB
  1. Apa cara terbaik untuk memigrasikan Django DB dari SQLite ke MySQL?

  2. Migrasi Laravel/db:seed super lambat

  3. Cara memperluas bidang yang dipisahkan koma menjadi beberapa baris di MySQL

  4. Tidak dapat menginstal mysqlclient di centos

  5. Aktifkan Dukungan Mesin Penyimpanan MySQL InnoDB di Instalasi XAMPP