MySQL() & SELECT LAST_INSERT_ID()

Colleagues, please tell me what I’m doing wrong.

I need to make entries in the database table. It has a primary key - it is an auto-increment type field int. After making a record, I need to return to this record. So I want to keep the primary key value of this record.

To do this, I read the key value after writing. Like this:

same  => n,MySQL(Connect connid localhost asterisk XXXXXXXXXXX MyBASE)
same  => n,MySQL(Query resultid ${connid} INSERT INTO `mytable` ...)
same  => n,MySQL(Query resultid ${connid} SELECT LAST_INSERT_ID())

Writing to the table is fine, but unfortunately, the readed value of uniq id is always two. Do not understand why.

The table itself is created correctly and all the necessary information is set.

CREATE TABLE `mytable` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  ...
  PRIMARY KEY (id)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

What am I doing wrong, tell me, please.

Ogogon.

MYSQL cmd is deprecated, I never use it , in your case I prefer Shell() function and MYSQL command, other will recomend you use ODBC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.