Java教程

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
这篇关于sql单表转左连接的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!