By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 3364508 fiddles created (36255 in the last week).
CREATE TABLE IF NOT EXISTS `Models` (
`Id` int(6) unsigned NOT NULL,
PRIMARY KEY (`Id`)
);
CREATE TABLE IF NOT EXISTS `Properties` (
`Id` int(6) unsigned NOT NULL,
PRIMARY KEY (`Id`)
);
CREATE TABLE IF NOT EXISTS `ModelProperties` (
`ModelId` int(6) unsigned NOT NULL,
`PropertyId` int(6) unsigned NOT NULL,
`Value` int(6) unsigned NULL,
PRIMARY KEY (`ModelId`, `PropertyId`)
);
INSERT INTO `Models` (`Id`) VALUES ('1'), ('2');
INSERT INTO `Properties` (`Id`) VALUES ('99'), ('100'); -- existing
INSERT INTO `Properties` (`Id`) VALUES ('101'), ('102'); -- new
INSERT INTO `ModelProperties` (`ModelId`, `PropertyId`) VALUES
('1', '99'), ('1', '100'),
('2', '99'), ('2', '100'), ('2', '101'); -- Model 2 updated to 101
Msg 156 Level 15 State 1 Line 1
Incorrect syntax near the keyword 'IF'.
Msg 102 Level 15 State 1 Line 1
Incorrect syntax near '`'.
Msg 102 Level 15 State 1 Line 5
Incorrect syntax near '`'.
Msg 102 Level 15 State 1 Line 9
Incorrect syntax near '`'.