SELECT
a.id,
a.serialNumber,
date_format(
a.create_time,
'%Y-%c-%d %h:%i:%s'
) AS create_time,
ifnull(a.create_by_name, '') AS create_by_name,
a.`status`,
ifnull(a.remarks, '') AS remarks,
(
SELECT
group_concat(n.`name`) AS main_product_name
FROM
ferp$pur$delivery_noticebilld_detail f
LEFT JOIN erp$product$product n ON f.product_id = n.id
WHERE
f.delivery_notice_billd_id = a.id
ORDER BY
f.id
LIMIT 3
) AS main_product_name,
a.run_status
FROM
ferp$pur$delivery_noticebilld a
WHERE
1 = 1
AND (
a.books = 'LD'
OR a.books = 'BD'
OR a.books = 'JGC'
)
AND DATE_FORMAT(a.create_time, '%Y/%m/%d') >= '2019/10/01'
AND DATE_FORMAT(a.create_time, '%Y/%m/%d') <= '2019/10/24'
AND EXISTS (
SELECT 1 FROM ferp$pur$delivery_noticebilld_detail d
LEFT JOIN erp$product$product p ON d.product_id = p.id
WHERE d.delivery_notice_billd_id = a.id and
p. NAME LIKE '%螺丝%'
)
ORDER BY
a.id DESC
EXISTS筛选条件
最新推荐文章于 2021-06-18 10:21:08 发布