在一些例子中,使用数据库表“shop”来储存某个商人(经销商)的每件物品(物品号)的价格。假定每个商人对每项物品有一个固定价格,那么(物品,商人)即为该记录的主关键字。
create table shop(
article int(4) unsigned zerofill default '0000' not null,
dealer char(20) default '' not null,
price double(16,2) default '0.00' not null,
primary key(article,dealer)
);
--------------------------
“最大的物品号是什么?”=select max(article) as article from shop;
任务:找出最贵物品的编号、销售商和价格。= select * from shop where price=(select max(price) from shop);