mysql sort

Joel Fentin joel at cts.com
Mon Aug 14 16:17:30 CDT 2000


~sdpm~
I can't get a sort from mysql. I get the correct data in the
wrong order. Nearly the same code works fine with DBD:ram.

The table name is table1. There are 16 fields named col1 thru
col16. All are TEXT. There are about 40 records. I am using very
recent perl and mysql in win95.

======================================

use strict;use DBI;

#open database-----------------------------------------
my $dbh =
DBI->connect("DBI:mysql:HHG",undef,undef,{PrintError=>0,RaiseError
=>0})|| print "TILT\n";

#will not sort-----------------------------------------
my $Names = $dbh->selectcol_arrayref("SELECT col3 FROM table1
WHERE col2 = 'Seafood' ORDER BY 'table1.col3'");
foreach (@$Names){print "$_\n"} 				#print seafood restaurant names

#will not sort-----------------------------------------
my @Name = @{$dbh->selectcol_arrayref("SELECT col3 FROM table1
WHERE col2 = 'seafood' ORDER BY 'table1.col3'")};
foreach (@Name){print "$_\n"} 				#print seafood restaurant names

#will not sort-----------------------------------------
my $sql ="SELECT col3 FROM table1 WHERE col2 = 'Seafood' ORDER BY
'table1.col3'";
my $sth = $dbh->prepare($sql);
$sth->execute()||print "tilt";
while (my $row = $sth->fetchrow_arrayref){print "@$row\n"};

$dbh->disconnect();
#======================================================
#open database-----------------------------------------
my $dbh =
DBI->connect('DBI:RAM:','usr','pwd',{RaiseError=>1});#open DB
$dbh->func({data_type=>'PIPE',file_source=>'HHGDb.txt',},'import');

#THIS SORTS BUT IT'S NOT MYSQL-------------------------
my $Names = $dbh->selectcol_arrayref("SELECT col3 FROM table1
WHERE col2 = 'Seafood' ORDER BY col3");#this works
foreach (@$Names){print "$_\n"} 				#print seafood restaurant names

$dbh->disconnect();




--
Joel Fentin    tel: 760-749-8863    FAX: 760-749-8864
 
email: joel at fentin.com                web: Fentin.com
~sdpm~

The posting address is: san-diego-pm-list at hfb.pm.org

List requests should be sent to: majordomo at hfb.pm.org

If you ever want to remove yourself from this mailing list,
you can send mail to <majordomo at happyfunball.pm.org> with the following
command in the body of your email message:

    unsubscribe san-diego-pm-list

If you ever need to get in contact with the owner of the list,
(if you have trouble unsubscribing, or have questions about the
list itself) send email to <owner-san-diego-pm-list at happyfunball.pm.org> .
This is the general rule for most mailing lists when you need
to contact a human.




More information about the San-Diego-pm mailing list