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.
| [reply] [Watch: Dir/Any] |
|
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
| [reply] [Watch: Dir/Any] [d/l] |
|
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>
| [reply] [Watch: Dir/Any] |
|
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.
| [reply] [Watch: Dir/Any] [d/l] [select] |
|
| [reply] [Watch: Dir/Any] |
|
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.
| [reply] [Watch: Dir/Any] |
|
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 :(
| [reply] [Watch: Dir/Any] |
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. | [reply] [Watch: Dir/Any] |