select dates.date_time dates, count(distinct tbl.user_id), sum(tbl.price)
from (
select distinct date(tbl.date_time) date_time from tbl
) dates
join tbl on dates.date_time >= date(tbl.date_time)
group by dates.date_time
order by dates.date_time;
<?php
бла-бла-бла ...
если (пользователь с таким именем существует) {
сообщение об ошибке
переход на страницу регистрации
закончили скрипт
}
если (пароль не совпадает с подтверждением) {
сообщение об ошибке
переход на страницу регистрации
закончили скрипт
}
если (не смогли переместить файл с аватаркой) {
сообщение об ошибке
переход на страницу регистрации
закончили скрипт
}
сохраняем нового пользователя в базу данных
сообщение об успешной регистрации
переход на страницу логина
закончили скрипт
?>
DELETE FROM dle_comments
WHERE NOT EXISTS (SELECT 1 FROM dle_post WHERE dle_post.id = dle_comments.post_id);
DELETE dle_comments.*
FROM dle_comments
LEFT JOIN dle_post ON dle_post.id = dle_comments.post_id
WHERE dle_post.id IS NULL;
SELECT * FROM `action` WHERE `condition` LIKE '%"action": "6"%';
select
posts.*,
json_objectagg(likers.user_id, likers.lname) lastnames,
json_objectagg(likers.user_id, likers.avatar) avatars
from posts
join (
select post_id, user_id, fname, lname, avatar, row_number() over (partition by post_id) rn
from likes
join users on users.id = likes.user_id
) likers on likers.post_id = posts.id
where likers.rn < 6
group by posts.id, posts.title, posts.description
;
SELECT
orders.num, orders.createdon, orders.cost, orders.status,
GROUP_CONCAT(products.name) prod_names,
GROUP_CONCAT(products.count) prod_counts,
GROUP_CONCAT(products.cost) prod_costs
FROM `modx_ms2_orders` AS orders
JOIN `modx_ms2_order_products` AS products ON orders.id = products.order_id
WHERE `user_id` = 106
GROUP BY orders.num, orders.createdon, orders.cost, orders.status
select * from (
select
*,
date(from_unixtime(created_at)) created_date,
row_number() over (partition by created_date order by created_at desc) rn
from tbl) row_numbers where rn = 1
select tbl.* from tbl
join (
select max(created_at) max_created_at
from tbl
group by date(from_unixtime(created_at))
) last_time on last_time.max_created_at = tbl.created_at;
create table questionnaires (
id int primary key auto_increment,
title varchar(255)
);
create table questios (
id int primary key auto_increment,
questionnaire_id int,
title varchar(255),
foreign key (questionnaire_id) references questionnaires(id)
);
create table answers (
id int primary key auto_increment,
question_id int,
title varchar(255),
rigth bool,
foreign key (question_id) references questios(id)
);
pool.query("SELECT * FROM users", (err, result)=>{
if (err) throw new Error(err.message);
res.send(result);
});
if(text === 'Магазин'){
man = connection.query('SELECT * FROM `products`', function(error,results){
if(error) {throw error}
for (let i in results) {
bot.sendMessage(chatId, `Продукты: \nИмя: ${results[i]['name']} Цена: ${results[i]['price']}`);
bot.sendMessage(chatId, results[i]['name']);
}
});
}
$stmt = $mysqli->prepare("INSERT INTO coins_info_table (coin_name_id) VALUES (?)");
$stmt->bind_param("s", $id);
foreach ($coin_name_id as $id) {
$stmt->execute();
}
UPDATE Admins A
JOIN Users U ON U.UserID = A.AdminID
SET A.password = U.password
WHERE U.UserID = 123;
UPDATE Admins
SET Admins.password = U.password
FROM Admins A JOIN Users U ON U.UserID = A.AdminID
WHERE A.AdminID = 123;