0

I came across mariadb, where I can do:

 INSERT INTO user (user_id, user_name) VALUES (1, 'hi') RETURNING *;

To return the whole row after inserting.

However, if I do the same thing in mysql, it would give me a syntax error.

Is there an equivalent in mysql that can return the whole row after inserting in a single statement?

wcyat
  • 67
  • 1
  • 2
  • 11
  • Does this answer your question? [MySql: Insert a row and get the content](https://stackoverflow.com/questions/5432756/mysql-insert-a-row-and-get-the-content) – Jonas Metzler May 22 '22 at 06:40
  • No, I would like it to be in one statement – wcyat May 22 '22 at 06:49
  • I cannot imagine a use for this feature how do you intend to use it? – P.Salmon May 22 '22 at 07:09
  • You asked whether it's possible to do do both insert and return the inserted data in one single query or even line. The linked topic tells you it's not. So do I understand correctly your question is not asked since you don't like the answer?? – Jonas Metzler May 22 '22 at 07:16
  • The use for this MariaDB feature is for when columns are autogenerated/trigger populated. When/if MySQL make this feature it will be in their [manual](https://dev.mysql.com/doc/refman/8.0/en/insert.html). Until then, MariaDB or `SELECT` statements are your alternatives. – danblack May 23 '22 at 00:39

0 Answers0