ALTER TABLE Products ADD FOREIGN KEY(vendorId) REFERENCES Vendors(id);
UPDATE
`test_table`
SET `id_to_col`= concat('<?php header("Location: <?=SITE_NAME;?>/index.php?action=view_ads&id=', test_table.id ,'")?>')
WHERE id = '4'
->addSelect(\DB::raw('(SUM(products_reviews.rating) / COUNT(products_reviews.id)) as `rating`'))
->addSelect(\DB::raw('
SELECT
(SUM(products_reviews.rating) / COUNT(products_reviews.id)) AS `rating`
FROM products_reviews
WHERE
products_reviews.product_id = products.id
AND products_reviews.is_published = 1
AND products_reviews.rating != 1
'))
-- для поля с типом DATETIME
ALTER TABLE table_name ADD CONSTRAINT check_for_current_year CHECK (YEAR(date_field) <= YEAR(GETDATE()));
-- для поля с типом YEAR
ALTER TABLE table_name ADD CONSTRAINT check_for_current_year CHECK (year_field <= YEAR(GETDATE()));
create server role blind_users;
deny view any database to blind_users;
alter server role blind_users add member login_name;
CREATE SEQUENCE tablename_colname_seq;
alter TABLE "Виплата" alter column "Код" type integer NOT NULL DEFAULT nextval('tablename_colname_seq');
ALTER SEQUENCE tablename_colname_seq OWNED BY "Виплата"."Код";
curl_setopt($ch, CURLOPT_REFERER, 'http://site.com/main-page');
SET @@sql_mode = 'TRADITIONAL';
DELIMITER $$
CREATE DEFINER=`root`@`%` TRIGGER `hlstats_Players_after_insert`
AFTER INSERT ON `hlstats_Players`
FOR EACH ROW
BEGIN
IF NEW.`game` = "tf" OR NEW.`game`= "tf2ser2" THEN
INSERT INTO data_orange SET playerId = NEW.playerId;
END IF;
END$$
ALTER TABLE `table_name` ADD UNIQUE (`language`, 'ID');
DELIMITER ;
DROP PROCEDURE IF EXISTS createLocalizedPage;
DELIMITER $
CREATE PROCEDURE createLocalizedPage(
IN language_in VARCHAR(20),
IN image_path_in VARCHAR(120),
IN page_content_in LONGTEXT
) SQL SECURITY INVOKER
BEGIN
DECLARE var_page_unique_id INT;
START TRANSACTION ;
IF (exists(SELECT 1 from `table_name` where image_path = image_path_in)) THEN
SET var_page_unique_id = (select max(`ID`) + 1 from `table_name`);
ELSE
SET var_page_unique_id = (select `ID` from `table_name` where image_path = image_path_in);
END IF;
INSERT INTO `table_name` (`language`, `image_path`, `page_content`, `ID`) VALUES
(language_in, image_path_in, page_content_in, var_page_unique_id);
COMMIT ;
END $
DELIMITER ;
INSERT INTO `table_name` (`language`, `image_path`, `page_content`, `ID`)
VALUES (
language_in,
image_path_in,
page_content_in,
CASE
WHEN exists(SELECT 1 from `table_name` where image_path = image_path_in) then
(select `ID` from `table_name` where image_path = image_path_in)
ELSE
(select max(`ID`) + 1 from `table_name`)
END
);