[本⽂出⾃天外归云的博客园]
有两张表,⼀张是商店商品表shop_productsshop_en_name
⼀张是商店信息表shop_infoshop_en_nameshop_cn_name
问题:查出了每个商店最贵的商品名、商品价格以及对应所在的商店中⽂名写法如下:
select
shop_products.product_name, max(price) as max_price, shop_info.shop_cn_namefrom
shop_products
left join shop_info on shop_products.shop_en_name = shop_info.shop_en_namegroup by
shop_products.shop_en_nameorder by
max_price desc
product_name
price
这⾥主要是对max函数以及联结查询的应⽤
因篇幅问题不能全部显示,请点此查看更多更全内容