Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Re^2: DBD::CSV - SQL Syntax - "AND" clause is not working properly

by slayedbylucifer (Scribe)
on Aug 28, 2012 at 11:26 UTC ( #990218=note: print w/replies, xml ) Need Help??

in reply to Re: DBD::CSV - SQL Syntax - "AND" clause is not working properly
in thread DBD::CSV - SQL Syntax - "AND" clause is not working properly

The missing ";" was a typo. My actual query looks like below:

my $query = "SELECT COLUMN3 FROM $table WHERE COLUMN1=\'$var1\' AND CO +LUMN2=\'$var2\'";

I already tried the "Single quotes" as above and it fails as well. I had to escape the single quotes else it won't interpret the Value that is stored in the variables.

Thanks for your time.

  • Comment on Re^2: DBD::CSV - SQL Syntax - "AND" clause is not working properly
  • Download Code

Replies are listed 'Best First'.
Re^3: DBD::CSV - SQL Syntax - "AND" clause is not working properly
by marto (Cardinal) on Aug 28, 2012 at 11:31 UTC

    When posting please provide an example which you are actually running, not doing this potentially wastes peoples time, posting unrelated code and a made up problem. I've provided a working example based on your csv file and the query you ran. Stop using variables like this, read and understand 'Placeholders and bind values' from the DBI documentation and never ever forget the ballad of Little Bobby Tables. SQL_injection.

      I understand your concern. But i cannot post the actual code as it has company sensitive information and will take me a day to edit that info from the code. so I always duplicate it with the test code and example and then only post it on the forum.

      thanks for your time.

        See How do I post a question effectively?, post a short example containing only code which contains no sensitive data which recreates the problem you're experiencing. Clearly on this occasion you didn't even run the test code you posted, never mind the fact that it wasn't even representative of the problem you were actually having. For the sake of existing replies, consider marking updates to your post if required (I notice you've added the semicolon).

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (6)
As of 2020-11-26 07:34 GMT
Find Nodes?
    Voting Booth?

    No recent polls found