Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: DBI selectall_arrayref

by eric256 (Parson)
on Sep 02, 2004 at 15:48 UTC ( [id://387943]=note: print w/replies, xml ) Need Help??


in reply to DBI selectall_arrayref

You used single quotes for the column names, that makes them strings . Use the backtick instead, ` and you should get what you want.


___________
Eric Hodges

Replies are listed 'Best First'.
Re^2: DBI selectall_arrayref
by davido (Cardinal) on Sep 02, 2004 at 15:59 UTC

    Use the backtick instead, `...

    Huh? Backticks are for executing commands via the operating system shell, and capturing their output. That's not going to help.


    Dave

      He's talking about an SQL quote interpretation issue, not a qx/q/qq issue:
      select 'string constant with spaces' from table select `column name with spaces` from table

      blokhead

        Thanks blokhead. My mistake. :)

        What was that old Usenet saying? ...Ask a question on Usenet and *maybe* you'll get an answer. Post something incorrect, and you'll get your answer for sure. <grin>


        Dave

      Not when inside another string. Backticks (and/or square brackets) are quotes for SQL barewords:
      "SELECT COL1,COL2 FROM TABLE"
      and
      "SELECT `COL1`,`COL2` FROM `TABLE`"
      are equivalent. It allows you to have columns with whitepace in the name:
      "SELECT `COL1 NAME`,`COL2 NAME` FROM TABLE"

      "SELECT 'COL1 NAME','COL2 NAME' FROM TABLE"
      would return something entirely different.

        :) Learn something new every day. Thanks ikegami. I guess I should have referred to the SQL manual before jumping to conclusions.


        Dave

      But they are quoted here from perl - these backticks would go to the SQL engine. Recently I've switched to PostgreSQL so I can't check it but perhaps MySQL uses them for quoting fields with spaces in them.

        In SQL, 'foo' is a string. "foo" is a quoted identifier. In MySQL, 'foo' is a string, and "foo" is also a string. So they made the identifier quotation mark the backtick, resulting in `foo`. MySQL isn't SQL :(

        Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }

Re^2: DBI selectall_arrayref
by THuG (Beadle) on Sep 02, 2004 at 17:08 UTC
    Ah, thanks, that's it. I tried first with "SELECT *" and got data. I then tried with backticks and brackets. Backticks work, brackets don't. Now however, I'm getting a lot of "in short at C:/Perl/site/lib/Net/MySQL.pm line 591." messages.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://387943]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2024-03-19 11:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found