Oops sorry about that, I was trying to change it form html to text format and hit 
send. It's Monday.
Any who, so you ran the -print $query;- bit and copied and pasted what that printed 
out directly into your 
Db program and it worked?
You didn't just type in the same thing thinking it's the same did you?

What what in the $Table variable?

DBI->trace traces the steps that a database is doing. Very handy for debugging, 
different levels of details, etc.
To use it you must be using the DBI module. Are you? If not you need to see if your 
module has any similar abilities.

Perldoc -m DBI
 search for '->trace'

-----Original Message-----
From: Gary Fung [mailto:[EMAIL PROTECTED]] 
Sent: Saturday, January 11, 2003 10:46 AM
To: Dan Muey
Subject: RE: Why can't use SQL "GROUP BY..."?


Thanks Dan 

 I 've tried the SQL command in Oracle. It works! Of course this simple SQL command is 
valid command. 

I've tried to print out the command you suggested. It seems nothing help. 

I wonder to hear you suggest to use DBI->trace. What is it? And how can I use it to 
solve the problem? 

Thank you for your reply.!! 

Gary 

  Dan Muey <[EMAIL PROTECTED]>?????: 

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 " 
QUERY -$query- 

\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]

Reply via email to