完全加入两个select语句

时间:2016-04-01 06:04:57

标签: mysql outer-join

这段代码出了什么问题,两个子选择语句都运行良好但是完全连接给我错误

select t1.*, t2.*
from (
    SELECT
        `users-transaction`.`users-transaction-id` as 'id-1',
     concat(`users-transaction`.`users-transaction-year`+ `users-transaction`.`users-transaction-month`+ `users-transaction`.`users-transaction-day`) as date1,
        sum(`users-transaction`.`users-transaction-price`) as gharzi
    FROM `users-transaction` 
    where  `users-transaction`.`users-transaction-type`=0 
        GROUP BY `users-transaction-year`, `users-transaction-month`, `users-transaction-day`
    ) t1
    full outer JOIN
   (

    SELECT  
        `users-transaction`.`users-transaction-id` as 'id-2',
     concat(`users-transaction`.`users-transaction-year`+ `users-transaction`.`users-transaction-month`+ `users-transaction`.`users-transaction-day`) as date2,
        sum(`users-transaction`.`users-transaction-price`) as pardakhti
    FROM `users-transaction` 
    where  `users-transaction`.`users-transaction-type`=1 
        GROUP BY `users-transaction-year`, `users-transaction-month`, `users-transaction-day`
    ) t2 on t1.date1=t2.date2

表格结构:

enter image description here

0 个答案:

没有答案