sql单表转左连接

索引字段

sql单表转左连接

SELECT
	b.id,
	pack_type AS packType,
	logistics_template AS logisticsTemplate,
	is_print AS isPrint,
	print_user AS printUser,
	DATE_FORMAT(
		create_tm,
		'%Y-%m-%d %H:%i:%s'
	) AS createTm,
	is_check AS isCheck,
	is_cancel AS isCancel,
	print_index AS printIndex,
	boxCode AS boxCode,
	shipmentPort AS shipmentPort,
	IFNULL(uploadState, 0) AS uploadState
FROM
	(
		SELECT
			id
		FROM
			tb_order
		WHERE
			(
				uploadState = '1'
				AND is_cancel = '0'
				AND order_status = '0'
			)
		ORDER BY
			modify_tm DESC
		LIMIT 0,
		100
	) tb_order2
LEFT JOIN tb_order b ON tb_order2.id = b.id
上一篇:MyBatis


下一篇:数据库增删改查