Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

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
Re^3: DBD::CSV - SQL Syntax - "AND" clause is not working properly
by marto (Chancellor) 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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2014-07-24 02:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (156 votes), past polls