大家好,欢迎来到IT知识分享网。
1.NOT EXITS语句
SELECT DISTINCT
c.ID as “id”,
c.MED_ID as “medId”,
c.SKU as “sku”,
c.COMMODITY_NAME as “commodityName”,
c.UNIT as “unit”,
c.IS_UNIFORM_PRICE as “isUniformPrice”,
c.IMAGE_ID as “imageId”,
c.DETAIL_IMAGE_ID as “detailImageId”,
c.SALE_DATE_BEGIN as “saleDateBegin”,
c.SALE_DATE_END as “saleDateEnd”,
c.IS_SEARCH as “isSearch”,
c.STATUS as “status”,
c.REMARK as “remark”,
c.CREATE_USER as “createUser”,
c.CREATE_TIME as “createTime”,
c.UPDATE_USER as “updateUser”,
c.UPDATE_TIME as “updateTime”
FROM yiyao_b2c.cmd_commodity c
JOIN yiyao_b2c.cmd_sale_attr s on c.ID=s.CMD_ID
left join yiyao_meta.med_medicine med on c.MED_ID = med.ID
WHERE
NOT EXISTS (
SELECT
t.CMD_ID
FROM
(SELECT mpm.CMD_ID,mpm.EXT_ITEM_ID
FROM
yiyao_meta.med_partner_medicine AS mpm
WHERE
mpm.PARTNER_ID = “xxxx”) t //查询出已经同步的商品
WHERE
c.ID =t.CMD_ID AND t.EXT_ITEM_ID IS NOT NULL //过滤已经同步的商品
)
2. 该sql的语义是:查询出没有做过同步的商品
3.标红的的部分是要注意的点
转载于:https://my.oschina.net/nixi0608/blog/735196
免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://yundeesoft.com/24393.html