Mysql query help needed

i have 3 tables
table A with …
table B with, B.A_id
table C with, C.A_id, C.type

table B and C can contain more records with A_id.

i need list of all record from A (regardless if there are records for A_id in table B or C),
record containing A_id in table B with max from ( from the records containing A_id for every,
record containing A_id in table C with type=o and max from ( from the records containing A_id for every

       max( as maxbid, 
       max( as maxcid
  from a
  left join b
    on = b.a_id
  left join c
    on = c.a_id
   and c.type = 0
 group by

thanks for the help, but i already tried that query and it does not return the correct results

the condition c.type = 0 is disregarded while max(
and if c.something is stated in the select c.something is not from the max( but from the first found record which is min(

sorry my bad about the type=0 disregarding (this happens if i join the table C table with table D and the d.type=0 - but this is not the problem)

the query returns the but c.something is incorrect

yeah, but there was no c.something in your original post, you just added it

and of course the query no longer works the way you want if you add it

select,a.aid from
author a,catalog c where a.aid=a.aid
and in (select bid from orderdetails group by bid having(qty) in (select max(sum(qty)) from orderdetails having sum(qty) group by bid));

the error is ERROR 1111 (HY000): Invalid use of group function

please help


do you know what the GROUP BY clause does?