in reply to Why is my code assigning the last-retrieved value to all elements in my hash?

Every $booklist_1{$book_id}{'update_id'} is being set to the first record of your SQL Query. You should change your loop for something like : while (@data = $sth->fetchrow_array()) { ... }
  • Comment on Re: Why is my code assigning the last-retrieved value to all elements in my hash?

Replies are listed 'Best First'.
Re^2: Why is my code assigning the last-retrieved value to all elements in my hash?
by kyle (Abbot) on Jul 09, 2008 at 16:56 UTC

    The OP's query returns only one record (it includes 'LIMIT 1'). On each loop, he executes the query for the new $book_id and then fetches that one record.