本笔记为阿里云天池龙珠计划SQL训练营的学习内容,链接为:https://tianchi.aliyun.com/specials/promotion/aicampsql
一、查询
1.准备数据
1.简单查询
select <列名> from <表名 >
SELECT 查询不会对数据库中的数据进行修改.只是一种显示数据的方式
1)查询product中所有的数据
select * from product; 这儿的 * 表示查询表中所有的列
2)查询product表中的所有记录,仅显示product_id和product_name字段
select product_id,product_name from product;
3)将所有的信息查询出来,并将列名改为中文
select
product_id as '编号',
product_name as '商品名',
product_type as '商品类型',
sale_price as '商品价格',
purchase_price as '购买价格',
regist_date as '购买日期'
from
product;
as用于给字段取别名,方便查询
4)查询一共有几个商品类型
注:distinct用于去重