MySQL Lists are EOL. Please join:

List:General Discussion« Previous MessageNext Message »
From:Butch Bean Date:January 28 2002 5:36pm
Subject:RE: Selecting the row with largest number in a column
View as plain text  
>You are correct... my apologies, I was thinking in VB where I built a
handler to let me sent multiple sql statements in one chunk and where the
'@' doesn't matter.

BB


This Works as a test...

my $getbigage = $dbh->prepare(
		"SELECT \@maxage:=max(age) from contacts");
my $getbigage1 = $dbh->prepare(
		"SELECT * FROM contacts WHERE age=\@maxage");

	$getbigage->execute();
	$getbigage1->execute();
	while(my @h = $getbigage->fetchrow_array()){
		print "The max age is ==> $h[0]\n";  #see the answer
	}

	my @list = ();
	my $target = undef;
	while(my @h = $getbigage1->fetchrow_array()){
		$fname = $h[0];
		$lname = $h[1];
		$age = $h[2];
		print "The contact(s) I was looking for ==> $fname, $lname, $age\n";
		push(@list, [$h[0],$h[1],$h[2]]);
	}

-----Original Message-----
From: Paul DuBois [mailto:paul@stripped]
Sent: Monday, January 28, 2002 11:28 AM
To: bbean-list@stripped; Richard Morton; DL Neil;
mysql@stripped
Subject: RE: Selecting the row with largest number in a column

>Perl Example:
>
>my $getbigage = $dbh->prepare(
>		"SELECT @maxage:=max(age) from contacts;".
>		"SELECT * FROM contacts WHERE age=@maxage;";

I don't believe this will work.  @ in double-quoted Perl strings must
be escaped with a backslash.  More important, you cannot issue multiple
queries at a time.  In the case above, the MySQL will return an error
indicating a syntax error at the semicolon that occurs within the string.


Thread
Re: [PHP-DB] any good web hosting with php and mysql support?clint 14 Jan
  • Re: [PHP-DB] any good web hosting with php and mysql support? (OT)Mikel King14 Jan
  • Re: [PHP-DB] any good web hosting with php and mysql support? (OT) Vlasyuk Valera14 Jan
RE: [PHP-DB] any good web hosting with php and mysql support?Rick Emery14 Jan
RE: [PHP-DB] any good web hosting with php and mysql support?NCI/IMS)14 Jan
  • RE: [PHP-DB] any good web hosting with php and mysql support?Shannon Kendrick14 Jan
    • Re: [PHP-DB] any good web hosting with php and mysql support? Vlasyuk Valera14 Jan
      • Selecting the row with largest number in a columnRichard Morton25 Jan
        • Re: Selecting the row with largest number in a columnJoseph Bueno25 Jan
        • Re: Selecting the row with largest number in a columnDL Neil25 Jan
          • Re: Selecting the row with largest number in a columnPaul DuBois25 Jan
          • RE: Selecting the row with largest number in a columnButch Bean25 Jan
            • Re: Selecting the row with largest number in a columnDL Neil26 Jan
            • RE: Selecting the row with largest number in a columnRichard Morton28 Jan
              • RE: Selecting the row with largest number in a columnButch Bean28 Jan
                • RE: Selecting the row with largest number in a columnPaul DuBois28 Jan
                  • RE: Selecting the row with largest number in a columnButch Bean28 Jan
                  • RE: Selecting the row with largest number in a columnButch Bean28 Jan
RE: [PHP-DB] any good web hosting with php and mysql support?Rick Emery14 Jan
RE: [PHP-DB] any good web hosting with php and mysql support?Boaz Yahav17 Jan