Home > Archive > PERL Beginners > July 2006 > mySQL SQL Statement trouble with WHERE
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
mySQL SQL Statement trouble with WHERE
|
|
|
| Hi..
Having trouble getting to the 'WHERE' to work in a sql statement.. The
statement I'm using is:
$query = qq{select UserName, UnitSN from tUser WHERE
tUser.Password="1password" };
my $sth = $dbh->prepare( $query ) or &dbdie;
$sth->execute or &dbdie;
The table has a Password entry with '1password' I can't get any
WHERE's to work.. What am I missing.. I have no problem with M$
ACCESS DB and the 'WHERE'..
mysql ver 5
installed perl driver today..
| |
| Paul Lalli 2006-07-25, 6:57 pm |
| IPA wrote:
> Having trouble getting to the 'WHERE' to work in a sql statement.. The
> statement I'm using is:
> $query = qq{select UserName, UnitSN from tUser WHERE
> tUser.Password="1password" };
> my $sth = $dbh->prepare( $query ) or &dbdie;
> $sth->execute or &dbdie;
>
> The table has a Password entry with '1password' I can't get any
> WHERE's to work..
Define "not work". What is going wrong? Syntax errors? Runtime
errors? You're not checking for any resulting rows above, so I assume
you don't mean that you're simply not getting the results you expect?
> What am I missing.. I have no problem with M$
> ACCESS DB and the 'WHERE'..
What, exactly, is making you think this is a Perl issue? What happens
when you paste that SQL into MySQL's native interface?
Paul Lalli
| |
|
| Here is the block of code:
$query = qq{select UserName, UnitSN from tUser WHERE
tUser.Password="1password" };
print "<BR>query: $query <br>";
my $sth = $dbh->prepare( $query ) or &dbdie;
$sth->execute or &dbdie;
@row = $sth->fetchrow_array;
if(! @row )
{
print "<br><h1> Nothing return!</h1><br>";
}
I expect to get returned data.. There is a entry in DB that meets the
request..
Paul Lalli wrote:
> IPA wrote:
>
> Define "not work". What is going wrong? Syntax errors? Runtime
> errors? You're not checking for any resulting rows above, so I assume
> you don't mean that you're simply not getting the results you expect?
>
>
> What, exactly, is making you think this is a Perl issue? What happens
> when you paste that SQL into MySQL's native interface?
>
> Paul Lalli
| |
| Paul Lalli 2006-07-25, 6:57 pm |
| IPA wrote:
> Paul Lalli wrote:
[color=darkred]
> Here is the block of code:
>
> $query = qq{select UserName, UnitSN from tUser WHERE
> tUser.Password="1password" };
>
> print "<BR>query: $query <br>";
> my $sth = $dbh->prepare( $query ) or &dbdie;
>
> $sth->execute or &dbdie;
>
> @row = $sth->fetchrow_array;
>
> if(! @row )
> {
> print "<br><h1> Nothing return!</h1><br>";
> }
>
> I expect to get returned data.. There is a entry in DB that meets the
> request..
Please do not top-post. Post your reply *below* what you are replying
to. I have corrected your follow-up style here.
You ignored my second question. What happens when you paste that line
of SQL into MySQL's native interface?
There is nothing wrong with the Perl code you've shown. Therefore,
there is something wrong with either: Perl you haven't shown (how is
&dbdie defined, I wonder?), your SQL, or your expectations.
Paul Lalli
|
|
|
|
|