电脑桌面
添加小米粒文库到电脑桌面
安装后可以在桌面快捷访问

Mysql查询语句大全VIP免费

Mysql查询语句大全_第1页
1/7
Mysql查询语句大全_第2页
2/7
Mysql查询语句大全_第3页
3/7
Mysql 查询语句大全 \1.两表之间的查询,例如:查询员工表中部门号与部门表中部门号相等 select * from tb_emp ,tb_dept where tb_emp.deptno=tb_dept.deptno; (这是同时显示两张表中相等的depton 所有字段)(tb_emp ,tb_dept 这都是表名) 2.select tb_e.deptno from tb_e, tb_d where tb_e.deptno=tb_d.deptno; (这是只显示员工表中的tb_e.deptno,并且条件是员工表中部门号与部门表中部门号相等) 3.给字段取别名 select product_price*12 totsl_product_price from productinfo; 等价select product_price*12 from productinfo; 也可以这样写 select product_price*12 " totsl product_price" from productinfo; 有特殊的字符时用双引号的方法,(特殊字符是:中文,日文,分号等)(totsl product_price是 product_price*12) ****** 0 和空 还有空格不是一个概念 例如: select * from emp where description is null; select * from emp where description =0; select * from emp where description ='空格'; 查询的结果都市不一样的。 distinct 关键字可以查询结果中清除重复的行,他的作用范围是后面的所有字段的组合; 例如: select distinct deptno ,deptname from emp where deptno=23; totsl_product_price 是product_price 的别名; select ename, sal*12 as '年薪'from emp; 别名的作用是 让查询出来的结果可以让别人(外行)看了一目了然的作用 上面是针对产品价格计算出总金额,价格*12,也就是对字段值进行加减乘除, *****任何含有空值的表达式计算后的值都是空值。( 空值+20=空值,等等) 不等值查询(mysql 两者都支持) select * from productinfo where product_id!=33; oracl 的不等值查询 select * from productinfo where product_id<>'33'; 小于查询 select * from productinfo where product_id<'33'; 大于查询 select * from productinfo where product_id>'33'; 等于查询 select * from productinfo where product_id='33'; 在一定值范围内查询 例如 1000--5000 的查询 select ename, sal as '月薪'from emp where sal>=1000 and sal<=5000; 在两个值之间的查询 between...... and (包含最小值和最大值) select ename, sal as '月薪'from emp...

1、当您付费下载文档后,您只拥有了使用权限,并不意味着购买了版权,文档只能用于自身使用,不得用于其他商业用途(如 [转卖]进行直接盈利或[编辑后售卖]进行间接盈利)。
2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。
3、如文档内容存在违规,或者侵犯商业秘密、侵犯著作权等,请点击“违规举报”。

碎片内容

Mysql查询语句大全

确认删除?
VIP
微信客服
  • 扫码咨询
会员Q群
  • 会员专属群点击这里加入QQ群
客服邮箱
回到顶部