题目是查询价格最高的书的书名、作者及价格;
use pubs;
select title,max(price) as '最贵的',au_lname,au_fname from authors,titles,titleauthor
where titles.title_id=titleauthor.title_id and titleauthor.au_id=authors.au_id
group by title,au_lname,au_fname,price
你分组的细粒度太小了。这么查询肯定数据很多了。
这题也没必要分组,为什么要分组?
根据价格进行排序,取第一条记录。
select title,price,au_lname,au_fname from authors,titles,titleauthor
where titles.title_id=titleauthor.title_id and titleauthor.au_id=authors.au_id
order by price desc limit 1