Home > database >  Since mysql and not the toughening, solving. (insert into a values (select Max (id) from 1 a))
Since mysql and not the toughening, solving. (insert into a values (select Max (id) from 1 a))

Time:10-06

Masters, you are also the following script, the following two kinds of results in different libraries is different, why? Want to the first result,
1) 1 65
166
2) 1 65
2 66

INSERT INTO function_group_auth (
Func_group_id,
Group_no
)
VALUES
(
(SELECT
Id
The FROM
(SELECT
MAX (func_group_id) + 1 AS id
The FROM
Function_group_auth) AS a),
65
),
(
(SELECT
Id
The FROM
(SELECT
MAX (func_group_id) + 1 AS id
The FROM
Function_group_auth) AS a),
66
);

CodePudding user response:

Mysql's hard to understand grammar
ERROR 1093 (HY000) : You can 't specify target table' function_group_auth 'for update in the FROM clause

CodePudding user response:

More complicated than this, I gave this to simplified, try again should be no problem
Build table
The CREATE TABLE ` function_group_auth_1 ` (
` func_group_id ` INT (11), NOT NULL COMMENT 'func_group_id,
` function_base_id ` INT (11), NOT NULL COMMENT 'function_base_id,
` group_name ` VARCHAR (50), NOT NULL COMMENT 'group_name,
PRIMARY KEY (` func_group_id `, ` function_base_id `)
) ENGINE=INNODB DEFAULT CHARSET=utf8
INSERT INTO function_group_auth_1 (
Func_group_id,
Function_base_id,
Group_name
)
VALUES
(
(SELECT
Id
The FROM
(SELECT
MAX (func_group_id) + 1 AS id
The FROM
Function_group_auth_1) AS a),
65,
'test'
),
(
(SELECT
Id
The FROM
(SELECT
MAX (func_group_id) + 1 AS id
The FROM
Function_group_auth_1) AS a),
66,
'test'
);

CodePudding user response:

What library under the first kind of circumstance?
  • Related