SELECT date,name,code,times,times1 FROM (( SELECT t1.date, t1.NAME, t1.CODE, t1.times, t2.times1 FROM table1 t1 LEFT JOIN table2 t2 ON t1.CODE = t2.CODE UNION SELECT t2.date, t2.NAME, t2.CODE, t1.times, t2.times1 FROM table1 t1 RIGHT JOIN table2 t2 ON t1.CODE = t2.CODE WHERE t1.CODE IS NULL )) AS temp ORDER BY date
标签:CODE,Union,times1,t2,t1,SQL,date,Server,times From: https://www.cnblogs.com/luyj00436/p/16720619.html