mysql中using

select * from (
SELECT
	u.utm_source
	,count(DISTINCT u.mobile) as new_user -- 登记用户
	FROM 表名 u
	WHERE u.created_time BETWEEN '2019-03-01 00:00:00' AND '2019-03-01 23:59:59'  and u.utm_source in ('param1','param2')
	GROUP BY u.utm_source
	ORDER BY new_user DESC
	) t
	LEFT JOIN
(
	SELECT abbr as utm_source, `name`, type
	FROM
	表名
	WHERE abbr != ''
) qudao USING(utm_source) ;#limit $page,$page_count

  其中的USING用法是:qudao.utm_source = u.utm_source,相当于:join 表名 as a on a.utm_source = u.utm_source

posted @ 2019-03-01 11:38  谦逊的铅笔  阅读(1325)  评论(0编辑  收藏  举报