SQL exists( select 1 from
2015-12-23 17:40
218 查看
use UnlockIndustry select * from Info_Coordinate as A join Info_Employee on A.EmployeeId=Info_Employee.EmployeeId Where exists( select 1 from ( select EmployeeId,MAX(CreateTime) as CreateTime from Info_Coordinate group by Info_Coordinate.EmployeeId ) as b where A.EmployeeId=b.EmployeeId and A.CreateTime=b.CreateTime) And Info_Employee.CompanyId='1306010001' /* 关联人员和地址表。 select * from info_A as A JOIN Info_B ON A.id=Info_B.id where exists() and info_B.Cid='' */
例子:
______________________________________________________________________________
use MyMvc select * from Info_Company select * from Info_Empoyee select * from Info_Empoyee left Join Info_Company on Info_Empoyee.CompanyID=Info_Company.CompanyID select * from Info_Empoyee where exists(select 1 from Info_Company where Info_Empoyee.CompanyId=Info_Company.CompanyID)
相关文章推荐
- MySQL中开启和使用通用查询日志的实例教程
- Memcached简介
- oracle插入大量数据
- SQL Server未找到或无法访问服务器
- Oracle 调度程序(scheduler)摘自一位大神
- 创建和关联内容数据库到指定Web应用程序和站点集
- mariadb
- 如何写出性能优良的SQL
- Oracle数据库几种启动和关闭方式
- 常用的mysql命令
- 【iOS】数据库FMDB的使用(一)
- (转)SQL对Xml字段的操作
- Memcached CAS 协议
- MSSQL Server 数据库备份还原常用SQL语句及注意
- SQL Server中中数据行批量插入脚本的存储实现
- PLSQL DEV工具挂载官方文档
- Redis的Java客户端Jedis的八种调用方式(事务、管道、分布式…)介绍
- win7 64位的PHP5.4安装redis扩展
- oracle 合并多行记录
- mysql中关于时间用法