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)

2
  • 1
    Have you checked the LAST_INSERT_ID() mysql function? Have you done a Google search on your problem topic? Commented Jun 1, 2014 at 11:32
  • possible duplicate of How to get the ID of INSERTed row in mysql? Commented Jun 1, 2014 at 12:07

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.