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 fro