我有兩個查詢,在同一張表上做相同的條件選擇。你能幫我解決這個重複問題嗎?如何刪除此SQL子句重複?
if exists(select count(1)
from (<table>) t
where (<condition>)
having count(1) = 1)
set @yes = 1
if @yes = 1
select @x = X
from (<table>) t
where (<condition>)
您可以添加具有預期結果的樣本記錄嗎? –