N
N
Ninja Mate2016-11-24 00:14:20
MySQL
Ninja Mate, 2016-11-24 00:14:20

How to make such a JOIN?

I don’t understand how to do it right JOIN
The first part works, in we get a selection sorted by "year month" and the number
We need to add almost the same thing from another table, but with the condition

WHERE eng_ur > 1
and all this between dates
SELECT concat( EXTRACT(YEAR FROM ps_datetime ), ' ' , MONTHNAME(ps_datetime) ) AS MyDate, 
COUNT(ps_id) AS x
FROM `patient_services` GROUP BY MyDate

JOIN(SELECT concat( EXTRACT(YEAR FROM eng_datetime ), ' ' , MONTHNAME(eng_datetime) ) AS MyDate, 
COUNT(eng_id) AS x
FROM `engagements` GROUP BY MyDate )

WHERE eng_ur > 1 AND ( eng_datetime BETWEEN '$date_start' AND '$date_finish' )) WHERE ( ps_datetime BETWEEN '$date_start' AND '$date_finish' )

How to do this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rsa97, 2016-11-24
@victorzadorozhnyy

Are you sure you want JOIN and not UNION?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question