select
t1.name,
t1.date1,
t2.date2
from persons t1
join (
select
name,
max(date2) as date2
from persons
group by name
) t2 on t2.name = t1.name and t2.date2 = t1.date2
(SELECT * FROM `history` WHERE `g_unix` >= '1540933200')
UNION
(SELECT * FROM `history` WHERE `g_unix` <= '1540933200' ORDER BY `g_unix` DESC LIMIT 5)
ORDER BY `g_unix` DESC
function delete_litres_book($hub_id){
global $mysqli;
//удаляем книги путем простановки options=0
$q = "UPDATE `litres_data` SET options=0 WHERE hub_id=" . $hub_id;
$mysqli->query($q);
}
select,
t1.title,
t2.category,
count(*)
from main_menu t1
join products t2 on t2.category = t1.id
where t1.title = '...'
group by t1.title, t2.category