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)

  

SQL exists( select 1 from的更多相关文章

  1. SQL Server判断对象是否存在 (if exists (select * from sysobjects )(转)

    1 判断数据库是否存在Sql代码 if exists (select * from sys.databases where name = ’数据库名’)    drop database [数据库名] ...

  2. 当SQL UPDATE遇到EXISTS(SELECT ...)时

    直接上例子. user表: ; -- ---------------------------- -- Table structure for user -- --------------------- ...

  3. SQL Server - select语句练习

    创建表和输入数据 CREATE TABLE STUDENT(SNO VARCHAR(3) NOT NULL,   SNAME VARCHAR(4) NOT NULL,   SSEX VARCHAR(2 ...

  4. SQL EXISTS

    一直对exists的用法不清楚,本次学习exists,并作出相应学习总结. 1.创造测试环境SYS@ora122>create table a(id )); SYS@ora122>inse ...

  5. Oracle SQL:select各类查询语句总结

    SQL查询语句总结 数据查询语言:即DML(Data Mannipulation Language)数据操纵语言,用于查询.操纵数据表资料行 本手册所有示例引用表均以TIPTOP GP  ERP数据库 ...

  6. SQL学习--Select(一)TOP、派生表、连接、谓词

    TOP关键字 WITH TIES t.title,sum(s.qty)as totalSales from sales s left join titles t on s.title_id=t.tit ...

  7. 关于SQL中SELECT *(星号)的危害论

    听闻有许多人是禁止开发人员在SQL中使用SELECT *的,这里翻译一下StackOverflow的一篇提问,个人认为相当客观 [SELECT *]危害主要有以下几点: 给数据消费者传数据的低效.当你 ...

  8. LINQ系列:LINQ to SQL Exists/In/Any/All/Contains

    1. Any 返回没有Product的Category var expr = from c in context.Categories where !c.Products.Any() select c ...

  9. 实例学习SQL的Select命令

    1.查找员工的编号.姓名.部门和出生日期,如果出生日期为空值,--显示日期不详,并按部门排序输出,日期格式为yyyy-mm-dd.select emp_no ,emp_name ,dept ,isnu ...

随机推荐

  1. 如何用极路由+OpenWrt+RTL电视棒搭建一台SDR服务器,并隐秘地捕获和传输数据

    0×00 前言 近期因为有个从异地捕获无线信号的需求,便尝试着用OpenWrt+公网IP搭建了一台SDR服务器.如果有小伙伴嫌SDR硬件天线看起来太乱.或者电脑没有足够的USB接口也可在局域网搭建SD ...

  2. 线段树基础模板&&扫描线

    线段树的单点更新+区间求和 hdu1166敌兵布阵 Input 第一行一个整数T,表示有T组数据. 每组数据第一行一个正整数N(N<=),表示敌人有N个工兵营地 ,接下来有N个正整数,第i个正整 ...

  3. Service

      一.什么是Service Service在后台运行,不与用户进行交互.在默认情况下,Service运行在应用程序进程的主线程中,如果需要在Service中处理一些网络连接等耗时的操作,那么应该将这 ...

  4. 插入备份数据 报 IDENTITY_INSERT 为 ON 时解决方法

    SQL Server 2008 R2 x64 下 事情是这样的, 使用Navcate的数据导出备份工具导出表的记录 INSERT INTO [xxx_users] VALUES (1, 'tom ', ...

  5. sublime-text3设置浏览器预览html

    选择:Tools - Build System - New Build Syatem... 或者:工具 - 编译系统 - 新编译系统 然后粘贴代码 { "cmd": [" ...

  6. 获取编辑框字符串,传入Intent

    private EditText etData; etData = (EditText) findViewById(R.id.etData); Intent i = new Intent(MainAc ...

  7. 【GoLang】GoLang for 中有多个循环变量怎么处理?

    代码示例: sum := , ; i <= && j <= ; i, j = i+, j- { t.Log("i: ", i) t.Log(" ...

  8. 【leetcode】Search in Rotated Sorted Array II

    Search in Rotated Sorted Array II Follow up for "Search in Rotated Sorted Array":What if d ...

  9. poj 2403

    http://poj.org/problem?id=2403 题意:就是给你m个单词,以及n段对话.每一个单词都有所对应的价值.求对话中的价值总和 题解:很简单,就是用单词和价值对应起来,然后再寻找就 ...

  10. SQL Server 2005中的分区表

    记录笔记: 转自 猪八戒学做网站 SQL Server 2005中的分区表(一):什么是分区表?为什么要用分区表?如何创建分区表? SQL Server 2005中的分区表(二):如何添加.查询.修改 ...