<div dir="ltr">In the line <div><span style="font-size:13px"><br></span></div><div><span style="font-size:13px">$q = "SELECT @rn:=@rn+1 AS RN, l.ID FROM logros l WHERE l.ID>?"</span></div><div class="gmail_extra"><br></div><div class="gmail_extra">Replace the double quotes (") with single quotes (') to prevent interpolation.</div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature"><div dir="ltr"><br><a href="mailto:shawn.c.carroll@gmail.com" target="_blank">shawn.c.carroll@gmail.com</a><br>Software Engineer<br>Soccer Referee</div></div></div>
<br><div class="gmail_quote">On Wed, Sep 30, 2015 at 1:23 PM,  <span dir="ltr"><<a href="mailto:richard@rushlogistics.com" target="_blank">richard@rushlogistics.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Wondering if anyone can lend a hand here. The set of queries below work when I just plug them directly into the MySQL console.  However, when I wrap them in perl they fail with SQL errors.<br>
<br>
   my @rn;<br>
   my $q = "set @rn = 0"'; # set row number var for query below in order to be able to iterate as a hash in <a href="http://featadd.tt" rel="noreferrer" target="_blank">featadd.tt</a><br>
   $sth = $dbh->prepare($q);<br>
   $sth->execute();<br>
<br>
   # for now in this same subroutine, let's get the sponsorships that these feats match<br>
   $q = "SELECT @rn:=@rn+1 AS RN, l.ID FROM logros l WHERE l.ID>?";<br>
   $sth = $dbh->prepare($q);<br>
   $sth->execute($lid);<br>
   my $log_ref = $sth->fetchall_hashref('RN');<br>
<br>
I get:<br>
<br>
DBD::mysql::st execute failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '= 0' at line 1 at <a href="http://test_sql.pl" rel="noreferrer" target="_blank">test_sql.pl</a> line 12.<br>
DBD::mysql::st execute failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ':=+1 AS RN, l.ID FROM logros l WHERE l.ID>'7'' at line 1 at <a href="http://test_sql.pl" rel="noreferrer" target="_blank">test_sql.pl</a> line 17.<br>
DBD::mysql::st fetchall_hashref failed: statement contains no result [err was 4 now 2000000000]<br>
<br>
Thanks for any help.<br>
_______________________________________________<br>
Chicago-talk mailing list<br>
<a href="mailto:Chicago-talk@pm.org">Chicago-talk@pm.org</a><br>
<a href="http://mail.pm.org/mailman/listinfo/chicago-talk" rel="noreferrer" target="_blank">http://mail.pm.org/mailman/listinfo/chicago-talk</a></blockquote></div><br></div></div>