Questions tagged [lastinsertid]

135 questions
0
votes
1 answer

MySQL - Output of last select in procedure with update and insert

I have a stored procedure that executes the following statements: A select to populate a variable An update utilizing said variable Another select to populate a second variable An insert using the second variable A select of last_insert_id() to…
TheBeege
  • 134
  • 1
  • 1
  • 13
0
votes
1 answer

Zend 2 + Postgresql views - getGeneratedValue()

I'm using views in Postgresql and I encounter a problem in Zend: I can't retrieve the last inserted value of an insert request. Example: I have an user_view and when I insert in, it does instead: INSERT INTO basic_user(name, email) VALUES [...];…
Vincent Caggiari
  • 307
  • 2
  • 10
0
votes
2 answers

How to get the value of id(primary key) in previous operation in MySQL

I am using MySQL. I need to insert one row into a table first, then I need to get the id of the inserted row. The code looks somewhat like the following: insert into mytable (column2, column3, column4) values('value2','value3','value4')or…
Steven
  • 24,410
  • 42
  • 108
  • 130
0
votes
0 answers

How to find last inserted id while using pdo transaction?

I'm using PDO in my web application. In a part of this application, I need to work with PDO Transactions. I need to know last inserted id of first query and use it in the second query, and then if no problem occurs, I will commit this…
Mohammad Saberi
  • 12,864
  • 27
  • 75
  • 127
0
votes
0 answers

MySQL, linking data, constructing keys, insert into and update

I have information relevant to specific groups of a table A. So I sort out these relevant groups and make an entry containing the group-specific information in a second table B. Up to this point no problem - even for me. Now every single element of…
user2370579
  • 321
  • 1
  • 4
  • 7
0
votes
1 answer

Universal SQL construct to retrieve the last row inserted

What would be the correct universal SQL construct to get the last row inserted (or it's primary key). The ID might be autogenerated by a sequence but I do not want to deal with the sequence at all! I need to get the ID by querying the table.…
ˈoʊ sɪks
  • 897
  • 1
  • 7
  • 10
0
votes
1 answer

MySQL Assuming autoincremented IDs based on multi value insert and first id

Just wanted to runt this by someone who knows more MySQL than myself I perform a MySQL insert where I insert say 10 rows in one query. Then when you get MySQL's last insert id, it gives you the ID of the first inserted ID. Is it safe to assume that…
jstats
  • 596
  • 4
  • 17
0
votes
2 answers

retrieve last updated column in mysql

I have a MySQL query that goes as follows (using Zend_Db): $sql = $handle->quoteInto("UPDATE board SET rank=rank+1 WHERE post_id=?", $postid); $handle->query($sql); (Rank isn't an auto-incrementing PK). I would like to now retrieve the value of…
adamcroft
0
votes
1 answer

phpmyadmin and mysql pdo lastInsertId()

i have this $query = "INSERT INTO players VALUES ( UUID(), :firstname, :lastname, :age, :birthplace, :height, …
Brady Latsha
  • 133
  • 3
  • 13
0
votes
1 answer

MySQL - insert into with foreign key index

Here is the scenario: I have 2 tables and 2 temporary tables. Before I insert user data to the official tables, I insert them to a temp table to let them do the checks. There is a company table with company info, and a contact table that has…
Tim Withers
  • 12,072
  • 5
  • 43
  • 67
-1
votes
1 answer

LastInsertId is returning 0, when using database/sql package with oracle driver

I am using database/sql package with oracle driver (“gopkg.in/rana/ora.v4”), when I am inserting the data, it’s LastInsertId Method is returning 0, while data is successfully inserted. Attaching code. package main import ( “database/sql” …
-1
votes
1 answer

How do you get the last inserted ID from a class into a redirect

I use the following code to insert data into mysql with php pdo (from a class): $this->pdo = $this->connectMySql(); if(isset($params['content'])){ $query = 'INSERT INTO pages SET menu_name = :menu_name, position = :position,…
-2
votes
1 answer

assign lastinsertid to a variable

I am basically a new programmer, with some Oracle experience from years gone by. I have a form that collects household and member information (which also has a dropdown with a database connection that connects to the database to retrieve a listbox…
D Sepp
  • 3
  • 3
-2
votes
1 answer

Adding data from c#form (visual studio) to mysql database and need to retrieve new record ID back on to form

I am very very new to programming (about a week) and I am currently doing a project on c#, sql for college. I have done well so far and able to add, delete and update rows on to mysql from visual studio form. I would like a label (label5) to be…
Boo
  • 419
  • 6
  • 13
-2
votes
2 answers

How do I add lastInsertId()?

Possible Duplicate: Can't get mysql_insert_id() to work I want to print the last inserted id using lastInsertId() on this function: private function adduser() { if (!empty($this->error)) return false; $params = array( …
Dreni
  • 161
  • 1
  • 5
  • 18
1 2 3
8
9