Page 1 of 1

SQL

Posted: Tue Aug 13, 2002 11:45 pm
by prasadharischandra
my coding is

for($count_sql1=$count_load;$count_sql1<$count_load_limit;$count_sql1++) {
$count_bag_pieces=mysql_query("SELECT
sum(pas_dep_bg_pcs) as pcs,sum(pas_rtn_bg_pcs) as pcs_r,pas_dep_flight,pas_rtn_flight
FROM pase_res
WHERE (pas_dep_flight='$flight_list_no' and pas_dep_status='B' and pas_dep_board_seq ='$count_sql1' ) or ( pas_rtn_flight='$flight_list_no'and pas_rtn_status='B' and pas_rtn_board_seq='$count_sql1')")or die(mysql_error());
while($pi=mysql_fetch_array( $count_bag_pieces))
{

$depart_flight_load=$pi['pas_dep_flight'];
$depart_Peices_load=$pi['pcs'];



########
$return_flight_load=$pi['pas_rtn_flight'];
$return_piece_load=$pi['pcs_r'];





//$p_bag=$pi['pcs'];
} }


error is


Mixing of GROUP columns (MIN(),MAX(),COUNT()...) with no GROUP columns is illegal if there is no GROUP BY clause

what 's wrong

Posted: Wed Aug 14, 2002 12:26 am
by 9902468
Try adding group by pcs

or

group by pcs_r

or

group by pcs, pcs_r

after your where clause.

I'm using postgres sql database myself, so don't know if this is one of mysql's "features"....

Anyway, before you do anything try that the query also returns data if you erase sum() clauses.

-9902468

Re: SQL

Posted: Wed Aug 14, 2002 2:05 am
by twigletmac
prasadharischandra wrote:Mixing of GROUP columns (MIN(),MAX(),COUNT()...) with no GROUP columns is illegal if there is no GROUP BY clause

what 's wrong
Well the error message does kinda tell you - and 9902468 pointed it out too - you don't have a GROUP BY clause.

Read up on this:
http://www.mysql.com/doc/en/SELECT.html
and
http://www.mysql.com/doc/en/Group_by_functions.html

The manual is your friend...

Mac

Re: SQL

Posted: Thu Aug 15, 2002 6:21 am
by prasadharischandra
hai mac,
i did it using two querys but it's not a good way .
write to me if u have like that problem how u are solving.
i highly appriciated u;re helping