SQL

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
prasadharischandra
Forum Commoner
Posts: 57
Joined: Thu May 09, 2002 2:19 am
Location: sri lanka
Contact:

SQL

Post 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
User avatar
9902468
Forum Commoner
Posts: 89
Joined: Thu Jun 06, 2002 6:39 am
Location: Europe

Post 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
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Re: SQL

Post 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
prasadharischandra
Forum Commoner
Posts: 57
Joined: Thu May 09, 2002 2:19 am
Location: sri lanka
Contact:

Re: SQL

Post 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
Post Reply