insert into products values (1, '2021-05-01', 150)
on conflict(id) do update
set
date = case when excluded.date > products.date then excluded.date else products.date end,
price = case when excluded.date > products.date then excluded.price else products.price end;
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)
);
<?php
$a = 717.83;
$b = 701.26;
$percent = (($a - $b) / $b) * 100;
echo $percent;
if ($percent >3 ) {
echo ' Percent more then 3';
} else {
echo ' Percent less or equal then 3';
}
SELECT
COUNT(case when d.created_at > NOW() - interval '7 days' then 1 else null end) as "7 days",
COUNT(case when d.created_at > NOW() - interval '14 days' then 1 else null end) as "14 days",
COUNT(case when d.created_at > NOW() - interval '1 month' then 1 else null end) as "1 month"
c.short_name
FROM documents_owners dow
INNER JOIN contractors_main c ON dow.contractor_id = c.id
INNER JOIN documents_main d ON dow.document_id = d.id
GROUP BY c.short_name
ORDER BY COUNT(dow.document_id) DESC
with sqlite3.connect('base.db') as conn:
cursor = conn.cursor()
cursor.execute(f"UPDATE inv SET nabor = json_replace(nabor, '$.id', 99) WHERE ids={ctx.author.id}")
con.commit()
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();
}