如何使用類似if或case的東西......如何將以下代碼合併爲一個?以動態方式結合了兩個T-SQL
if @para = 'test'
begin
select * from Table A where status='A' and id in (select id from Table B)
end
else if @para = 'others'
begin
select * from Table A where status='A' and id in (select id from Table c)
end
像SELECT * FROM表A其中id在如果@para = XXX然後(從表B中選擇的id)
感謝。
你能否詳細說明多一點,你在找依據的情況下,查詢? –
是的!我想將兩個SQL合併成一個。我可以這樣做嗎? @ArunprasanthKV – chloe06060
實際上這是一個子查詢... ...像select * from table where col1 = xxx and col2 = xxx and id in(................).. so if我使用的情況下,..恐怖味精會提示子查詢不能做到這一點 – chloe06060