标签:mic join 例子 image where 记录 rtm mys span

select * from tableA,tableB;

select * from tableA,tableB where tableA.id=tableB.refer_id;

也可以用一下方法进行内连接查询:
select * from tableB inner join tableA on tableB.refer_id=tableA.id; --inner join -- on --用法
select tableA.id,tableA.name,tableB.name from tableB inner join tableA on tableB.refer_id=tableA.id;



select employee.name,department.dept_name from department
inner join employee
on department.dept_id=employee.dept_id; -- 内连接查询,此时from A inner join B 中 顺序无所谓

select employee.name,department.dept_name from department left join employee on department.dept_id=employee.dept_id; -- from 那个表 就以那个表为主 就是 显示那个表 select employee.name,department.dept_name from employee left join department on department.dept_id=employee.dept_id; -- from 那个表 就以那个表为主 就是 显示那个表

select employee.name,department.dept_name from employee
inner join department
on department.dept_id=employee.dept_id
and department.dept_id=201;

select department.dept_name from department
inner join employee
on department.dept_id=employee.dept_id
and employee.age>25;
select DISTINCT department.dept_name from department
inner join employee
on department.dept_id=employee.dept_id
and employee.age>25; -- DISTINCT 去重

标签:mic join 例子 image where 记录 rtm mys span
原文地址:https://www.cnblogs.com/pyhan/p/12335838.html