select count(*) from ec_subcategories where subcategory_id=:subcategory_id and sort_key=:sort_key select count(*) from ec_subcategories where subcategory_id=:next_subcategory_id and sort_key=:next_sort_key update ec_subcategories set sort_key=:next_sort_key where subcategory_id=:subcategory_id update ec_subcategories set sort_key=:sort_key where subcategory_id=:next_subcategory_id