0

Here is my code:

$result1 = mysqli_query($con, "INSERT INTO third (id2, language, divid, point, ce, datetime, IP)  VALUES ('$id2', '$language', '$new_divid', 0, 'b', NOW(), '$ipaddress')"); 

In this code (MySQL) I add a new line to the database and I didn't add a id1 column to it, cause id1 is auto-increment in the table - it adds id1 automatically.

Now what I am trying is tp get id1 back, inside the same SQL command BUT I don't want use PHP again and again. Is this possible?

Note: I saw something like OUTPUT INSERTED.id1 but I didn't understand what it is and whether i can use it. (I saw it in this question)

Community
  • 1
  • 1
user3301042
  • 352
  • 2
  • 14
  • 1
    Have you checked the `LAST_INSERT_ID()` mysql function? Have you done a Google search on your problem topic? – marekful Jun 01 '14 at 11:32
  • possible duplicate of [How to get the ID of INSERTed row in mysql?](http://stackoverflow.com/questions/7501464/how-to-get-the-id-of-inserted-row-in-mysql) – potashin Jun 01 '14 at 12:07

0 Answers0