我们如何在选定的表格上应用FULL OUTER JOIN等操作?

时间:2017-01-27 06:01:50

标签: mysql join left-join full-outer-join

我正在从两个不同的表中收集图表数据。我以前申请过左连接,但我只是预订了图表。

我希望它可以预订两次访问。 表是 预订表

    bookid | uid | dateTime
    --------------------------
    1      | 2   | 2017-01-20 12:55

和访问表

visitid | dateTime         | ip_Address
-----------------------------------------
1       | 2017-01-20 12:55 | 192.168.1.2

我的SQL查询在

下面
Select a.date,ifnull(a.bookings,0) AS bookings,ifnull(b.visits,0) as visits
from
(
(SELECT DATE( date ) as date , COUNT( booking_id ) AS bookings FROM  `booking` GROUP BY DATE( date )) As a 
FULL OUTER JOIN 
(SELECT DATE(date) as date,COUNT( ip_address ) as visits FROM visit_counter group by DATE(date)) As b
on a.date = b.date 
)
WHERE a.date BETWEEN (NOW( ) - INTERVAL 14 DAY) AND NOW( )  
ORDER BY a.date ASC

此处Full Outer Join引发语法错误。 以前我已经应用了Left Join,它正在运行。

0 个答案:

没有答案