in reply to Re: DBI selectall_arrayref
in thread DBI selectall_arrayref

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

Replies are listed 'Best First'.
Re^3: DBI selectall_arrayref
by blokhead (Monsignor) on Sep 02, 2004 at 16:04 UTC
    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

Re^3: DBI selectall_arrayref
by ikegami (Patriarch) on Sep 02, 2004 at 16:06 UTC

    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

Re^3: DBI selectall_arrayref
by zby (Vicar) on Sep 02, 2004 at 16:05 UTC
    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' }