MySQL Forums
Forum List  »  Perl

How to use quotation marks in query-strings ?
Posted by: Tim Vantag
Date: January 29, 2007 01:28AM

Hi ?

I have a small problem.

When I run this sql-query in mysql prompt, it works fine:
SELECT s.name, CONCAT('"',f.lastname, '"')AS lastname FROM `firsttable` f, `secondtable` s WHERE f.id = s.tID AND something="1";

RESULTS:
Mike "Johnson"
Elton "John"

But. When I try to run this query in perl-program I get errors because of CONCAT
String found where operator expected

My sql-query looks like this:
my $sql = "SELECT s.name, CONCAT('"',f.lastname,'"')AS lastname FROM `firsttable` f, `secondtable` s WHERE f.id = s.tID AND something='$variableID'";

my $sth = $database_connection->prepare($sql);
$sth->{RaiseError} = 1;
$sth->execute(); 
my $reference;
$reference = $sth->fetchall_arrayref;


So how I should write this CONCAT that I can run it into my perl prgram ?

Options: ReplyQuote


Subject
Written By
Posted
How to use quotation marks in query-strings ?
January 29, 2007 01:28AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.