一.基本查询语句 select的基本语法格式如下: select 属性列表 from 表名和视图列表 [ where 条件表达式1 ] [ group by 属性名1 [ having 条件表达式2 ] ] [ order by 属性名2 [ asc | desc ] ] 属性列表参数表示需要查询的字段名: 表名和视图列表参数表示从此处指定的表或者视图中查询数据,表和视图可以有多个: 条件表达式1参数指定查询条件: 属性名1参数指按照该字段的数据进行分组: 条件表达式2参数满足该表达式的数据才能
mysql> #查询每个栏目最贵的商品 mysql> select goods_id,shop_price,cat_id from (select goods_id,shop_price,cat_id from goods order by shop_price desc) as temp group by cat_id; +----------+------------+--------+ | goods_id | shop_price | cat_id | +----------+----
1.创建student和score表 CREATE TABLE student ( id INT(10) NOT NULL UNIQUE PRIMARY KEY , name VARCHAR(20) NOT NULL , sex VARCHAR(4) , birth YEAR, department VARCHAR(20) , address VARCHAR(50) ); 创建score表.SQL代码如下: CREATE TABLE score ( id INT