A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© qaz1070608974 中级黑马   /  2016-4-9 13:08  /  356 人查看  /  0 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

1.查询所有的商品.                select * from product;
2.查询商品名和商品价格.        select pname,price from product;
3.别名查询,使用的as关键字,as可以省略的.       
   3.1表别名: select * from product as p;
   3.2列别名:select pname as pn from product;       
4.去掉重复值.        select distinct price from product;
5.查询结果是表达式(运算查询):将所有商品的价格+10元进行显示.
   select pname,price+10 from product;
6.查询商品名称为十三香的商品所有信息:
    * select * from product where pname = '十三香';
7.查询商品价格>60元的所有的商品信息:
    * select * from product where price > 60;
where后的条件写法:
    * > ,<,=,>=,<=,<>
    * like 使用占位符 _ %  _代表一个字符 %代表任意个字符.
        * select * from product where pname like '%%';
    * in在某个范围中获得值.
        * select * from product where pid in (2,5,8);

评分

参与人数 1黑马币 +4 收起 理由
chengda + 4 很给力!

查看全部评分

0 个回复

您需要登录后才可以回帖 登录 | 加入黑马