if exists(select 1
from chat_lastread
where `user_id` = #user_id
and `dialog_id` = #dialog_id)
begin
update chat_lastread
set `date` = NOW()
from chat_lastread
where `user_id` = #user_id
and `dialog_id` = #dialog_id
end
else
begin
INSERT INTO chat_lastread (
`user_id`,
`dialog_id`,
`date`
) VALUES(
#user_id,
#dialog_id,
NOW()
)
end
select dd.tovar_id, dd.sender_id
from dialogs dd
where not exists(select 1
from dialogs ds
where ds.tovar_id = dd.tovar_id
and ds.recipient_id = dd.dd.sender_id
and ds.id < dd.id)
group by dd.tovar_id, dd.sender_id
def find_key(dct, key):
try:
if dct.get(key):
return dct[key]
else:
for k in dct.values():
val = find_key(k, key)
if val:
return val
except:
return
Resp = dict()
Resp["abc"] = dict()
Resp["2"] = dict()
Resp["abc"]["find"] = 1
Resp["2"]["find_1"] = 2
print(find_key(Resp, "find_1"))
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'