Search the MySQL manual:
MySQL Manual

Buy this Reference Manual in softcover from Barnes & Noble!

/ / Up / Table of Contents

8.4.6.2 Какие результаты можно получить из запроса?

В дополнение к возвращенному запросом результирующему набору данных можно также получить следующую информацию:

User Comments

Posted by Alex Moreno on Wednesday December 18 2002, @5:27pm [Delete] [Edit]

I'd like to point out something about
LAST_INSERT_ID().

Certainly, if you do:

INSERT INTO foo (auto, text)
VALUES (NULL, 'text');

and then:

SELECT LAST_INSERT_ID();

you will get the id assigned to that row. BUT, if
you do something like:

INSERT INTO foo (auto, text)
VALUES (NULL, 'text1'),
(NULL, 'text2'),
(NULL, 'text3');

Then, LAST_INSERT_ID() will give you the id of the
row with the 'text1' value!

So, if for example, foo has no rows before
this
multiple INSERT, after this INSERT the value
returned by LAST_INSERT_ID() will be 1, even
though the table has inserted three ids (1, 2 and
3, naturally).

Maybe this is how it should work, but it
didn't
seem so to me =)

Add your own comment.

Top / / / Up / Table of Contents