select bname, max(cid) maxid, cname from a, b, c where b.id = a.bid and c.aid = a.aid and c.cid = maxid
不一定对,跑跑看.