I apologize if this has already been covered to but... Can you run that command by hand and does it work? Do this to see is both $Table has a value and if the generated code is actaully a valid sql command.
$query = "SELECT page FROM $Table GROUP BY page"; print "<P> QUERY -$query- <P> \n" $value2 = $dbh->prepare($query) || die "Couldn't add record, ".$dbh->errstr(); Then paste the query into your program and see if it takes it. IE Mysql> SELECT page FROM monkey GROUP BY page; You could also you use DBI->trace. Again if this has already been covered sorry, I've been away. Dan -----Original Message----- From: Philip Newton [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 09, 2003 11:34 PM To: Gary fung Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: Re: Why can't use SQL "GROUP BY..."? On Thu, 9 Jan 2003 22:59:03 +0800 (CST), [EMAIL PROTECTED] (Gary fung) wrote: > My coding is similar as: > > $value2 = $dbh->prepare("SELECT page FROM $Table > > GROUP BY page") || die "Couldn't add record, ".$dbh->errstr(); > > Whenever I use "GROUP BY.." , an error statement will go out : > > "SQL ERROR: Can't find table names in FROM clause!" Others have pointed out the possibility that $Table may be empty. I'd like to add that I think there's another error -- as far as I know, GROUP BY can only be used when you have aggregate functions such as SUM, MAX, COUNT(...) etc. (For example, "SELECT custno, count(ordernum) FROM orders GROUP BY custno ORDER BY 2 DESC" to select the customers together with the number of orders, grouped by customer but sorted by number of orders.) Did you mean ORDER BY, perhaps? Cheers, Philip -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]