zoukankan      html  css  js  c++  java
  • SQL exists( select 1 from

    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)
    

      

  • 相关阅读:
    VirtualBox 使用技巧
    ThreadPoolExecutor 线程池任务队列分析 与 利特尔法则(Little's law)
    AQS 与 LockSupport
    Matrix
    Fire Net
    Travelling
    Cannon
    N皇后问题
    Safecracker
    #include <algorithm>中sort的一般用法
  • 原文地址:https://www.cnblogs.com/blogs2014/p/5070684.html
Copyright © 2011-2022 走看看