mysql> select * from table1; +----+------+-----------+ | id | name | addr | +----+------+-----------+ | 1 | Tom | Beijing | | 2 | Lee | 123 | | 3 | Lee | 123 | | 4 | wu | chongqing | +----+------+-----------+ 4 rows in set (0.00 sec) mysql> insert into table1(name, addr) values("feng", "chengdu"); Query OK, 1 row affected (0.00 sec) mysql> select last_insert_id; ERROR 1054 (42S22): Unknown column 'last_insert_id' in 'field list' mysql> select last_insert_id(); +------------------+ | last_insert_id() | +------------------+ | 5 | +------------------+ 1 row in set (0.00 sec) mysql> select last_insert_id() as lastid; +--------+ | lastid | +--------+ | 5 | +--------+ 1 row in set (0.00 sec) mysql>