php - How to insert a new Dataset in a temporary Table and get the new id using Mysql? -
i try insert data in temporary table, when call select last_insert_id() return allways same number. have set autoincement setting.
in normal table works, when copy normal table temporary table, have problem select last_insert_id().
this code:
create temporary table if not exists suchergebnisse_temp (select * suchergebnisse); insert suchergebnisse_temp set datensatzid='2865', datum='2015-05-13 00:00:00', tabelle='task', sortierung1='1'; select last_insert_id();
the normal table:
create table if not exists `suchergebnisse` ( `id` bigint(20) not null auto_increment, `tabelle` varchar(100) not null default '0', `datensatzid` bigint(20) not null default '0', `datum` datetime not null, `sortierung1` int(11) not null comment 'priorität', primary key (`id`) ) engine=myisam default charset=utf8 comment='temporäre tabelle.';
can me? :)
i forgot add key explicit temporary table. needs execute following code:
alter table `suchergebnisse_temp` change column `id` `id` bigint(20) not null auto_increment first, add primary key (`id`);
because with:
create temporary table if not exists suchergebnisse_temp (select * suchergebnisse);
copys field data not key data. key data must declared separately.
Comments
Post a Comment