DELETE FROM b_iblock_section WHERE IBLOCK_ID=4 LIMIT 100;
SELECT purc.client_id, purc.action_date as DatePrch, srv.action_date as DateSrv
FROM [action_log] purc
INNER JOIN [action_log] srv
ON srv.client_id = purc.client_id
AND srv.action_date > purc.action_date
AND srv.action_type = 'service'
WHERE action_type = 'purchase'
AND action_date >= DATEADD(hour, -24, GETDATE())
ORDER BY action_date DESC
UPDATE requests
SET requests.title = "договор для АО",
requests.responsible = ISNULL((SELECT id
FROM users
WHERE username = "переменная с текстом"), requests.responsible),
requests.datecreate = "2018-09-18",
requests.percent = "0",
comment = "коммент",
status = ISNULL((SELECT id
FROM status
WHERE status = "переменная с текстом"), requests.status)
FROM requests
WHERE requests.id = 4
SELECT
sign(coalesce(location_id, 0)) + sign(coalesce(division_id, -1)) + sign(coalesce(position_id, -2)) as score, title
FROM
keyword
WHERE
city_id = $cityId AND
(division_id = $divisionId OR division_id IS NULL) AND
(position_id = $positionId OR division_id IS NULL) AND
(location_id = $locationId OR location_id IS NULL) AND
MATCH (keyword) AGAINST ('$keys')
GROUP BY
title
ORDER BY
score
DESC LIMIT 10
select t1.id
from table t1
where t1.my_column_4 = 'Polyps'
and t1.my_column_5 = 'normal'
and exists(select 1
from table t2
where t2.id = t1.id
and t2.Date > t1.Date
and t2.my_column_4 = 'CRC'
and t2.my_column_5 = 'Futher Procedure')