update checkanaliz set id_napravlenie = 1 where id_napravlenie = 2
delete from napravlenie where id = 2
$countryN->execute([':id' => $countries_id]);
$rows = $countryN->fetchAll();
var_dump($rows);
$row = $countryN->fetch();
var_dump($row);
select *
from (select parent, product,
rank() over (partition by parent order by price) price_rnk
from t2
) a
where price_rnk = 1
select case
when a.begin is null and a.end is null then 'нет данных'
when a.begin is not null and a.end is not null then concat(a.end, '-', a.begin)
when a.begin is null and a.end is not null then concat('ранее ', a.end + 1)
when a.begin is not null and a.end is null then concat('от ', a.begin)
end interval_str,
cnt
from
(
select inters.begin, inters.end, count(prepod.name) cnt
from
(
select null begin, 1969 end union all
select 1970 begin, 1979 end union all
select 1980 begin, 1989 end union all
select 1990 begin, 1999 end union all
select 2000 begin, null end union all
select null begin, null end -- запись для тех, у кого нет данных др.
) inters -- таблица с интервалами
left join
(
select 'a' name, STR_TO_DATE('2013-02-11', '%Y-%m-%d') date_r union all
select 'aa' name, STR_TO_DATE('2010-09-01', '%Y-%m-%d') date_r union all
select 'b' name, STR_TO_DATE('1968-02-11', '%Y-%m-%d') date_r union all
select 'bb' name, STR_TO_DATE('1969-01-21', '%Y-%m-%d') date_r union all
select 'c' name, STR_TO_DATE('1980-02-11', '%Y-%m-%d') date_r union all
select 'd' name, STR_TO_DATE('1989-02-11', '%Y-%m-%d') date_r union all
select 'z' name, null date_r -- препод, у которого нет данных др.
) prepod on inters.begin <= year(prepod.date_r) and inters.end >= year(prepod.date_r)
or inters.begin is null and inters.end >= year(prepod.date_r)
or inters.begin <= year(prepod.date_r) and inters.end is null
or prepod.date_r is null and inters.begin is null and inters.end is null
group by inters.begin, inters.end
order by inters.begin desc, inters.end desc
) a
UPDATE dle_users
SET user_balance = user_balance + round(user_balance / 100.0, 2)
UPDATE dle_users
SET user_balance = user_balance + ceil(user_balance / 100.0 * 100) / 100.0
^ ^
корректировка ceil по 2 знакам после запятой
SELECT count(e.id) "кол-во записей example со статусом 1",
(
select count(type_id)
from example e_1
where type_id = 1
and e_1.status = 3
) "кол-во для типа 1",
(
select count(type_id)
from example e_3
where type_id = 3
and e_3.status = 3
) "кол-во для типа 3",
(
select count(type_id)
from example e_4
where type_id = 4
and e_4.status = 3
) "кол-во для типа 4"
FROM example e
WHERE e.status = 1
and e.user_id = 53;
SELECT count(e.id) "кол-во записей example со статусом 1",
count(case when e.type_id = 1
and e.status = 3 then 1 end) "кол-во для типа 1",
count(case when e.type_id = 3
and e.status = 3 then 1 end) "кол-во для типа 3",
count(case when e.type_id = 4
and e.status = 3 then 1 end) "кол-во для типа 4"
FROM example e
WHERE e.status = 1
and e.user_id = 53;
SELECT count(case when e.status = 1 then 1 end) "кол-во записей example со статусом 1",
count(case when e.type_id = 1
and e.status = 3 then 1 end) "кол-во для типа 1",
count(case when e.type_id = 3
and e.status = 3 then 1 end) "кол-во для типа 3",
count(case when e.type_id = 4
and e.status = 3 then 1 end) "кол-во для типа 4"
FROM example e
where e.user_id = 53
-- Считаем статус 1, игнорируем типы
SELECT 'with_status_1' type_query, null type_id, count(*) cnt
FROM example e
where e.status = 1
and e.user_id = 53
union all
-- Считаем остальные типы со статусом 3
SELECT 'with_another_types' type_query, e.type_id, count(*) cnt
FROM example e
where e.status = 3
and e.user_id = 53
group by e.type_id
SET @var = 4;
Select * from
(
-------------Ваш сложный подзапрос --------------------
SELECT *
FROM menu
WHERE FIND_IN_SET(ID,(SELECT GROUP_CONCAT(lv SEPARATOR ',') FROM (
SELECT @pv:=(SELECT GROUP_CONCAT(ID SEPARATOR ',')
FROM menu WHERE submenu IN (@pv)) AS lv FROM menu
JOIN (SELECT @pv:=@var)tmp
WHERE submenu IN (@pv)) a))
UNION ALL
SELECT *
FROM menu
WHERE ID = @var
ORDER BY ID
-------конец сложного подзапроса--------------
) complicated_menu
inner join ваша_таблица vt on complicated_menu.id = vt.id
Try this. Check /etc/php7/
Rename 20_mysqli.ini to 30_mysqli.ini, or delete 20_mysqli.ini if both exist. If you also have 20_openssl.ini there, rename that to 10_openssl.ini.
Above change is needed to load the modules in the correct order.
This should now be fixed in the latest builds, but you could be running older code, or suffering from the bug that was there earlier.
$out_arr = array();
while($hero2 = mysqli_fetch_assoc($hero1))
{
$time_now = strtotime($hero2['cron1']);
$time_need = strtotime($hero2['cron2']);
if($time_need>=$time_now ){
$t_s= date("H:i ",75600-($time_need-$time_now));
}
else
$t_s= date("H:i ",75600-($time_now-$time_need));
$out_arr[] = str_replace(":",".",$t_s);
}
echo "[".join(' ,', $out_arr).']';
SELECT shop_product.id, if(shop_product_skus.count >= 3, shop_product_skus.count, 0) as count
FROM shop_product
join shop_product_skus on shop_product.id = shop_product_skus.product_id
WHERE
shop_product.id IN (14770, 13287, 14160, 13906)
select country.country_id
from country
select c.country_id
from country c
select ctry.id
from country ctry
select *
from t as t1
join t as t2 on t1.user_id1 = t2.user_id2
AND t2.user_id1 = t1.user_id2
select count(*) as work_day_count --считаем, что осталось после отсечения выходных и праздников
from (SELECT distinct t1.*, t1.c1 + INTERVAL iterator.day DAY as dt_day
FROM (select STR_TO_DATE("01.10.2018", "%d.%m.%Y") c1, STR_TO_DATE("22.10.2018", "%d.%m.%Y") c2 union all
select STR_TO_DATE("22.10.2018", "%d.%m.%Y") c1, STR_TO_DATE("10.11.2018", "%d.%m.%Y") c2 ) t1 --таблица с проверяемыми интервалами
join (select @start_day := @start_day + 1 as day
from news, -- любая произвольная таблица с числом строк, больше чем ширина максимально возможного интервала дней, который можно рассмотреть этим запросом
(select @start_day := -1) init_day --инициализация переменной start_day
) iterator --итератор дней, ведет отсчет с 0 и до куда надо (до максимального интервала, который может быть)
on (t1.c1 + INTERVAL iterator.day DAY) <= t1.c2 --верхнее ограничение итератора
and (t1.c1 + INTERVAL iterator.day DAY) not in -- отсекаем выходные и праздники
(select STR_TO_DATE("06.10.2018", "%d.%m.%Y") c1 union all
select STR_TO_DATE("07.10.2018", "%d.%m.%Y") c1 union all
select STR_TO_DATE("13.10.2018", "%d.%m.%Y") c1 union all
select STR_TO_DATE("14.10.2018", "%d.%m.%Y") c1 union all
select STR_TO_DATE("20.10.2018", "%d.%m.%Y") c1 union all
select STR_TO_DATE("21.10.2018", "%d.%m.%Y") c1 union all
select STR_TO_DATE("27.10.2018", "%d.%m.%Y") c1 union all
select STR_TO_DATE("28.10.2018", "%d.%m.%Y") c1 union all
select STR_TO_DATE("03.10.2018", "%d.%m.%Y") c1 union all
select STR_TO_DATE("04.11.2018", "%d.%m.%Y") c1 union all
select STR_TO_DATE("10.11.2018", "%d.%m.%Y") c1 union all
select STR_TO_DATE("11.11.2018", "%d.%m.%Y") c1) -- тут делаем выборку выходных дней и праздников
order by dt_day ) a
select a.*
from (select d.id, d.tovar_id, d.sender_id, d.recipient_id, d.message,
case
when d.sender_id < d.recipient_id
then d.sender_id * 1000000 + d.recipient_id
else d.recipient_id * 1000000 + d.sender_id
end dialog_hold
from dialogs d
where d.tovar_id = :tovar_id
and (d.sender_id = :user_id or d.recipient_id = :user_id)
) a
order by a.tovar_id, a.dialog_hold, a.id
DELETE FROM videos WHERE id = ?
$ids = R::getAssoc('SELECT id FROM videos');
$videos = R::find( 'videos', 'id = ?', $ids );