It's really quite simple:
my %hash = ( id => 'foo', id => 'bar', id => 'baz', );
Now, what is the value of $hash{id}? It is baz, because that was the last key/val pair in the list. You know that hashes behave this way, why should DBI do something different?

Here is a little test you might be interested in:

my $sth = $dbh->prepare('select 1,1,1'); $sth->execute; print Dumper $sth->fetchrow_hashref; $sth->execute; print Dumper $sth->fetchrow_arrayref; $sth = $dbh->prepare('select 1 as a,1 as b,1 as c'); $sth->execute; print Dumper $sth->fetchrow_hashref;
Even when you are dealing with just SQL, this is expected behavior. It is not at all uncommon to use column aliases, and if you really did "distinguish ... the fields in order to get the select to work" then you "shouldn't have to do it twice to get the hashref to work". Remember, just qualifying the column by appending the table name to it DOES NOT change the column name:
mysql> select baz.foo, baz.bar from baz;
+---------------+------+
| foo           | bar  |
+---------------+------+
| <tag> & stuff |    0 |
| one           |    1 |
| two           |    2 |
| three         |    3 |
| zero          |    0 |
| null          | NULL |
+---------------+------+
6 rows in set (0.00 sec)

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

In reply to Re: Hash-clobbering in DBD's fetchrow_hashref by jeffa
in thread Hash-clobbering in DBD's fetchrow_hashref by Cody Pendant

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.