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')
select prt.ball
from price_ratings prt
where prt.type_name = 'price_items'
union
select prt.ball
from price_ratings prt
left join price_items pr
on pr.price_id = prt.type_id
left join price_ratings pp
on pp.type_id = pr.id
and pp.type_name = 'price_items'
where prt.type_name = 'price'
and pp.ball is null
select isnull(prt.ball, pri.ball)
from price_items pi
left join price_ratings prt
on prt.type_id = pi.id
and prt.type_name = 'price_items'
left join price_ratings pri
on pri.type_id = pi.price_id
and pri.type_name = 'price'
SELECT u.event_id,
u.event_name,
u.start_date,
u.end_date,
u.serv_id,
d.name,
c.client_nm as cli
FROM tevents u
LEFT OUTER JOIN doctors d
ON d.id = u.type
LEFT OUTER JOIN clients c
ON c.id = u.combo_select
WHERE u.start_date between '2018.05.23 06:00:00' and '2018.05.23 21:50:00'