Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

new to perl, very simple question fetchrow 1

Status
Not open for further replies.

AlbertAguirre

Programmer
Joined
Nov 21, 2001
Messages
273
Location
US
I am selecting 2 columns in my SQL. I only know how to use fetchrow.
How do i tell perl to get the second table column specified in my sql?

Heres my code:

$p_detSql=$dbh1->prepare ("SELECT firstname, lastname FROM tNetworkDet");
$p_detSql->execute();
$lastname=$p_detSql->fetchrow(); <-- doesnt work

How do I get lastname?
 
Assign fetchrow to an array rather than a scaler, then the results are elements of the array.
Here is an example from one of my progs.
Code:
my $sql="SELECT EMAIL,U,P FROM ARTISTS WHERE EMAIL='$SENDML' AND BIRTH='$BTOWN'";
my $sth=$dbh->prepare($sql);
$sth->execute();
@results=$sth->fetchrow_array();
print "$results[0] - $results[1] - $results[2]<br>";

Keith
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top