How to find the date range from the database and display only the duplicate?

Hello. There's a code.
$nnomer = $_POST['nnomer'];
const SQL_GET_MENU_ITEM = '
SELECT datestart, dateend FROM main WHERE namenomer = :namenomer
';
try{
$pdo = new PDO("mysql:host=127.0.0.1;dbname=module;charset=utf8","root","");
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

$stmt = $pdo->prepare(SQL_GET_MENU_ITEM);
$res = $stmt->execute([':namenomer' => $nnomer]);
$row = json_encode($stmt->fetchAll(PDO::FETCH_OBJ));
echo "$row";
}catch(PDOException $e ){
exit( $e->getMessage());
}

DB looks at me like this:
1df143df96a548ca8a433400417fad81.PNG
The principle of operation of a script: From the site goes an ajax request with $_POST['nnomer']; (it is equal to lux), php inserts it into a pdo query to the database and gets the answer. Answer - first and last date of the date range. In my case the answer is:
[{"datestart":"2016-11-29","dateend":"2016-12-03"},{"datestart":"2016-12-01","dateend":"2016-12-05"}]

Only 4 dates, but in fact there will be more.
So. Tell me how using php to find recurring dates? In my case, the recurring date is: 2016-12-01, 2016-12-02 and 2016-12-03. Is that possible to do?
July 2nd 19 at 13:54
1 answer
July 2nd 19 at 13:56
Write a query where you group and print the date where count > 2
Ala something
select count(datestart) as cnt, datestart FROM youTable
GROUP BY datestart
HAVING cnt > 1


condition complete themselves.. that would between have been

Find more questions by tags PHPDatabases