zoukankan      html  css  js  c++  java
  • 关于Left join

    Sql关联表时条件放在On或者where上结果是不一样的。

    1.放在on上 如下

    select S.StoreID,* from BizProductItem as P
    left join BizStore as S on P.ProductCode=S.ProductCode and S.StoreID = 'BJ-warehouse'
    where P.IsValid='1' and P.Status = '0' and P.ProductCode like 'B%'
    order by P.ProductCode

    表示先取出符合条件的数据再关联

    2.放在where上表时用全部数据关联,再取出符合条件的数据

    select S.StoreID,* from BizProductItem as P
    left join BizStore as S on P.ProductCode=S.ProductCode
    where P.IsValid='1' and P.Status = '0' and S.StoreID = 'BJ-warehouse' and P.ProductCode like 'B%'
    order by P.ProductCode

    两种查询的结果不同

  • 相关阅读:
    求某个数的位数公式
    ArrayList和lInkedList比较
    队列
    抽象数据结构-栈
    LinkedList的实现
    ArrayList的实现
    Iterator和List的一些问题
    SCHEMA约束
    DTD约束
    XML解析
  • 原文地址:https://www.cnblogs.com/lidaying5/p/5634876.html
Copyright © 2011-2022 走看看