Greetings-

I'm hoping that someone else has run into this issue before. The trouble I am having is that I am getting the following error for my Update statement:

#42000You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"UPDATE my_table SET MY_COLUMN = '' WHERE MY_OTHER_COLUMN = 'my_value'"' at line 1 at mysql_connect.pl line 24.

I have verified that the same statement executes successfully using the MySQL CLI, so I'm not sure what syntax Perl is finding objectionable...


My setup is as follows:

* I am running Perl(ActivePerl-5.10.0.1003-MSWin32-x86-285500) and the MySQL(5.0.51b) DB on Windows XP

* I am using the http://search.cpan.org/dist/Net-MySQL-0.09 module

And now the code (you will note the Select statement that comes prior to the Update statement, which is not throwing any errors):

my $mysql = Net::MySQL->new( hostname => 'localhost', database => 'my_DB', user => 'root', password => 'my_password' ); $mysql->query(q{"SELECT * FROM my_table WHERE MY_OTHER_COLUMN LIKE 'my +_value'"}); $mysql->query(q{"UPDATE my_table SET MY_COLUMN = '' WHERE MY_OTHER_COL +UMN = 'my_value'"}); die $mysql->get_error_message if $mysql->is_error;
Thanks for any help you can provide, and please let me know if I have forgotten to include anything relevant.

In reply to MySQL "Update" statement is failing with syntax error by carpediem

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.