i have many categories with display mode “static block only”, but anchor by this categories is “yes”.

For example, i can change this attribute for ALL categories with query:
SELECT * FROM eav_attribute where attribute_code = 'is_anchor';
UPDATE catalog_category_entity_int set value = 0 where attribute_id = 51;
How can i change with sql query a attribute is_anchor to “no”, only if the attribute display_mode is “static block only’?