I want to change two fields in one table with one query. It's looks like this
UPDATE SavedStoreModel
SET storePosition =:secondItemPosition
WHERE storePosition =:firstItemPosition,
storePosition =:firstItemPosition
WHERE storePosition =:secondItemPosition
But this query is don't executable because of coma. A query like this works fine without where condition, but how to do this with multiple where?
答案 0 :(得分:1)
UPDATE SavedStoreModel
SET storePosition = case when storePosition = :firstItemPosition
then :secondItemPosition
else :firstItemPosition
end
WHERE storePosition in (:firstItemPosition, :secondItemPosition)