zoukankan      html  css  js  c++  java
  • 【MySQL】mysql-left join陷阱

    .where和and的差异

    SELECT
        ota_distributor_product_relation.ota_id,
        ota_distributor_product_relation.ota_name,
        ota_distributor_product_relation.sale_status,
        ota_distributor_product_relation.id,
        ota_stock_price.guide_price,
        ota_stock_price.purchase_price,
        ota_stock_price.scenic_price,
      ota_stock_price.stock
    FROM
        ota_distributor_product_relation
    LEFT JOIN ota_stock_price ON ota_distributor_product_relation.id = ota_stock_price.relation_id
    AND ota_distributor_product_relation.ticket_id='06d02f2d583746f2ad7ac4a0407f3499' AND ota_stock_price.sp_date='2017-06-29'

    SELECT
        ota_distributor_product_relation.ota_id,
        ota_distributor_product_relation.ota_name,
        ota_distributor_product_relation.sale_status,
        ota_distributor_product_relation.id,
        ota_stock_price.guide_price,
        ota_stock_price.purchase_price,
        ota_stock_price.scenic_price,
      ota_stock_price.stock
    FROM
        ota_distributor_product_relation
    LEFT JOIN ota_stock_price ON ota_distributor_product_relation.id = ota_stock_price.relation_id
    where ota_distributor_product_relation.ticket_id='06d02f2d583746f2ad7ac4a0407f3499' AND ota_stock_price.sp_date='2017-06-29'

     

    可以看到两种查询得到的结果不一样,具体原因可以查看这篇博文:

    http://www.oschina.net/question/89964_65912

    以前没注意,不知道是不是写了很多bug = =。

  • 相关阅读:
    install kde in ubuntu
    Upgrade to or Install Cinnamon 2.4 in Ubuntu
    enjoy dollar vs cash dollar
    opencv linux
    高频交易都有哪些著名的算法
    wpf
    opencv mat flags含义
    gphoto2 canon eos450d
    gphoto2
    task optimization之superglue分析
  • 原文地址:https://www.cnblogs.com/flydkPocketMagic/p/MySQL.html
Copyright © 2011-2022 走看看