Итак, окончательные варианты скриптов:
Постеры (не помечаются эпизоды):
/*$$IBEC$$ ПОСТЕРЫ $$IBEC$$*/
INSERT INTO
CUSTOM_VALUES_SHORTSTR
("cmfid", "mid", "value")
SELECT
'40' as "cmfid", "mid", 'Нет Постера' as "value"
FROM
MOVIES
WHERE
"mid" NOT IN (SELECT "mid" FROM CUSTOM_VALUES_SHORTSTR WHERE "cmfid" = '40' AND "value" = 'Нет постера') AND
"visible" = -1 AND "epid" is NULL AND
(NOT EXISTS(SELECT FIRST 1 * FROM IMAGES WHERE ("mid" = MOVIES."mid") AND ("imgtype" = 0)));
commit;
DELETE FROM
CUSTOM_VALUES_SHORTSTR
WHERE
("cmfid" = 40) AND ("value" = 'Нет постера') and
(EXISTS(SELECT FIRST 1 * FROM IMAGES WHERE ("mid" = CUSTOM_VALUES_SHORTSTR."mid") AND ("imgtype" = 0)));
commit;
Скриншоты (помечаются эпизоды):
/*$$IBEC$$ СКРИНШОТЫ $$IBEC$$*/
INSERT INTO
CUSTOM_VALUES_SHORTSTR
("cmfid", "mid", "value")
SELECT
'40' as "cmfid", "mid", 'Нет Скриншотов' as "value"
FROM
MOVIES
WHERE
"mid" NOT IN (SELECT "mid" FROM CUSTOM_VALUES_SHORTSTR WHERE "cmfid" = '40' AND "value" = 'Нет Скриншотов') AND
"visible" = -1 AND
(NOT EXISTS(SELECT FIRST 1 * FROM IMAGES WHERE ("mid" = MOVIES."mid") AND ("imgtype" = 1)));
commit;
DELETE FROM
CUSTOM_VALUES_SHORTSTR
WHERE
("cmfid" = 40) AND ("value" = 'Нет Скриншотов') and
(EXISTS(SELECT FIRST 1 * FROM IMAGES WHERE ("mid" = CUSTOM_VALUES_SHORTSTR."mid") AND ("imgtype" = 1)));
commit;
CD Обложка (не помечаются эпизоды):
/*$$IBEC$$ CD ОБЛОЖКИ $$IBEC$$*/
INSERT INTO
CUSTOM_VALUES_SHORTSTR
("cmfid", "mid", "value")
SELECT
'40' as "cmfid", "mid", 'Нет CD Обложки' as "value"
FROM
MOVIES
WHERE
"mid" NOT IN (SELECT "mid" FROM CUSTOM_VALUES_SHORTSTR WHERE "cmfid" = '40' AND "value" = 'Нет CD Обложки') AND
"visible" = -1 AND "epid" is NULL AND
(NOT EXISTS(SELECT FIRST 1 * FROM IMAGES WHERE ("mid" = MOVIES."mid") AND ("imgtype" = 3)));
commit;
DELETE FROM
CUSTOM_VALUES_SHORTSTR
WHERE
("cmfid" = 40) AND ("value" = 'Нет CD Обложки') and
(EXISTS(SELECT FIRST 1 * FROM IMAGES WHERE ("mid" = CUSTOM_VALUES_SHORTSTR."mid") AND ("imgtype" = 3)));
commit;
Box Обложка (не помечаются эпизоды):
/*$$IBEC$$ Box ОБЛОЖКИ $$IBEC$$*/
INSERT INTO
CUSTOM_VALUES_SHORTSTR
("cmfid", "mid", "value")
SELECT
'40' as "cmfid", "mid", 'Нет Box Обложки' as "value"
FROM
MOVIES
WHERE
"mid" NOT IN (SELECT "mid" FROM CUSTOM_VALUES_SHORTSTR WHERE "cmfid" = '40' AND "value" = 'Нет Box Обложки') AND
"visible" = -1 AND "epid" is NULL AND
(NOT EXISTS(SELECT FIRST 1 * FROM IMAGES WHERE ("mid" = MOVIES."mid") AND ("imgtype" = 2)));
commit;
DELETE FROM
CUSTOM_VALUES_SHORTSTR
WHERE
("cmfid" = 40) AND ("value" = 'Нет Box Обложки') and
(EXISTS(SELECT FIRST 1 * FROM IMAGES WHERE ("mid" = CUSTOM_VALUES_SHORTSTR."mid") AND ("imgtype" = 2)));
commit;
Если хотим видеть русские буквы в программе, сохраняем скрипт в кодировке UTF и открываем в редакторе скриптов.
Не забываем изменять значение "40", "Нет Постера", "Нет Скриншотов", "Нет CD Обложки", "Нет Box Обложки" на свои.