<?xml version="1.0" encoding="windows-1252"?>
<node id="990214" title="DBD::CSV - SQL Syntax - &quot;AND&quot; clause is not working properly" created="2012-08-28 07:11:31" updated="2012-08-28 07:11:31">
<type id="115">
perlquestion</type>
<author id="879310">
slayedbylucifer</author>
<data>
<field name="doctext">
&lt;p&gt;
Hello Monks.
&lt;/p&gt;
&lt;p&gt;
I am using DBI and the CSV driver DBD::CSV for manipulating the the CSV files. my SELECT query is not interpreting the way I want it ot.
&lt;/p&gt;
&lt;p&gt;
e.g., consider following table called test.csv:
&lt;/p&gt;
&lt;code&gt;
OS,RELEASE,VERSION
Ubuntu,Warty,4
Ubuntu,Hoary,5
Ubuntu,Breezy,5
Fedora,Yarrow,1
Fedora,Tettnang,2
Fedora,Stentz,4
&lt;/code&gt;
&lt;p&gt;
So, I want to list the version for Fedora Stentz which is "4".
&lt;/p&gt;
&lt;p&gt;
I have written below query:
&lt;/p&gt;
&lt;code&gt;
my $query = "SELECT VERSION from test.csv WHERE OS="Fedora" AND RELEASE="Stentz";
my $sth = $dbh-&gt;prepare ($query);
$sth-&gt;execute;
&lt;/code&gt;
&lt;p&gt;
However, I get below error:
&lt;/p&gt;
&lt;code&gt;
DBD::CSV::st execute failed: No such column '"Fedora" AND RELEASE="Stentz"' at /usr/local/lib/perl/5.10.1/DBI/DBD/SqlEngine.pm line 796
&lt;/code&gt;
&lt;p&gt;
So, This means the use of "AND" clause is causing the problem. I have worked a little bit on Oracle DB and know that the above Query would work fine on Oracle DB.
&lt;/p&gt;
&lt;p&gt;
however, I am not able to put "AND" clause to work in above query.
&lt;/p&gt;
&lt;p&gt;
I hve referred the documnetion @ [mod://SQL::Statement::Syntax] (which is used by DBD::CSV), however it doensn't talk much about the "AND" clause usage.
&lt;/p&gt;
&lt;p&gt;
Could you help in correcting the query please.
&lt;/p&gt;
&lt;p&gt;
-Thnaks.
&lt;/p&gt;
</field>
</data>
</node>
