Mysql和Oracle下的select,while,null,DESC和ASC,distinct,

落日映苍穹つ 2022-10-19 04:27 151阅读 0赞

– 查询单列
select prod_name from products;
– 查询多列
select prod_id,prod_name,prod_price from products
– 查询所有列
select * from products;
– distinct查询唯一的供应商ID(去重)
select distinct vend_id from products;
– 没有筛选之前
select vend_id,prod_price from products;
– distinct作用与所有的列,不仅是跟在其后的那一列
select distinct vend_id,prod_price from products;
– 排序(默认升序)ASC
select prod_name from products order by prod_name;
– 按照价格降序排列DESC
select prod_id,prod_name,prod_name from products order by prod_price desc;
– 多列排序:查询商品id,价格,名称并按照价格、名称升序
select prod_id,prod_price,prod_name from products order by prod_price desc,prod_name;
– 查询商品id,价格,名称并按照价格降序,名称升序
select prod_id,prod_price,prod_name from products order by prod_price desc,prod_name;
– where等值查询
select prod_name,prod_price from products where prod_price=3.49
– 查询名称为King doll的商品名称与价格
select prod_name,prod_price from products where prod_name=‘King doll’;
– where范围查询
select prod_name,prod_price from products where prod_price < 10
– 查询不是供应商DLL01制造的商品
select vend_id,prod_name from products where vend_id != ‘DLL01’
– 查询价格在5到10美元的商品
select vend_id,prod_name,prod_price from products where prod_price between 5 and 10;
– null值判断:查询邮箱地址为null的顾客
select cust_id,cust_name,cust_address from customers where cust_email is null;
– 查询邮箱地址不为null的顾客
select cust_name,cust_email from customers where cust_email is not null;

发表评论

表情:
评论列表 (有 0 条评论,151人围观)

还没有评论,来说两句吧...

相关阅读

    相关 MysqlOracle区别

    1、本质区别 大家最熟悉的,最根本的区别就是mysql是开源免费的,oracle是付费的 2、数据库和表名 mysql中数据库名和表名不区分大小写,oracle中区

    相关 OracleMysql区别

    一、并发性 oracle使用行级锁,对资源锁定的粒度要小很多,只是锁定sql需要的资源,并且加锁是在数据库中的数据行上,不依赖与索引。所以oracle对并发性的支持要好很多

    相关 MySQLOracle区别

    一、宏观上: 1、Oracle是大型的数据库而Mysql是中小型数据库;Mysql是开源的,Oracle是收费的,且价格昂贵。 2、Oracle支持大并发,大访问量,是