这个SQL语句是正确的。它从demand_delivery_command_header表中选择了多个列,并通过左连接将demand_delivery_command_item表与demand_delivery_command_header表关联起来。还使用了一个左连接将bos_order_header表与demand_delivery_command_header表关联起来。然后,使用WHERE子句过滤了一些条件,并使用GROUP BY子句对id进行分组。\n\n```SELECT\n\theader.id,\n\theader.create_by,\n\theader.create_time,\n\theader.doc_id,\n\theader.base_entry,\n\theader.order_no,\n\theader.ship_type,\n\theader.remark,\n\theader.doc_status,\n\theader.business_status,\n\theader.overseas_invoice_no,\n\theader.contact,\n\theader.address,\n\theader.tel,\n\titem.base_line_no,\n\titem.order_line_no,\n\titem.product_id,\n\titem.product_name,\n\titem.quantity,\n\titem.unit,\n\titem.demand_quantity,\n\titem.product_store_id,\n\titem.facility_id,\n\titem.product_store_id_to,\n\titem.facility_id_to,\n\titem.header_id,\n\tboh.user_id,\n\tboh.user_name,\n\theader.plan_delivery_time,\n\theader.is_invalid\nFROM\n\tdemand_delivery_command_header header\n\t\tleft join demand_delivery_command_item item on header.id = item.header_id\n\t\tLEFT JOIN bos_order_header boh ON boh.order_code = header.order_no\nWHERE\n\theader.plan_delivery_time < CURDATE()\nAND\n\titem.demand_quantity > 0\nAND\n\t(item.quantity-item.demand_quantity) > 0\nAND\n\t(header.is_invalid != 'Y' OR header.is_invalid is null)\nAND header.doc_status != '3'\nGROUP BY id\n

SQL语句检测工具 - 验证您的SQL语句是否正确

原文地址: https://www.cveoy.top/t/topic/pMYL 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录