慕森王
2018-12-06 12:46:19
有倆張表,一張是地區(qū)表里面的字段是【地區(qū)、對(duì)應(yīng)的信息】,另一張表是關(guān)鍵字表【關(guān)鍵字、對(duì)應(yīng)的信息】,我想通過(guò)存儲(chǔ)過(guò)程判斷,如果關(guān)鍵字表里面有信息者返回,不進(jìn)行別的查詢(xún),如果沒(méi)有這對(duì)地區(qū)表里面查詢(xún),返回地區(qū)表里面信息,請(qǐng)大神們幫忙
5 回答

DIEA
TA貢獻(xiàn)1820條經(jīng)驗(yàn) 獲得超2個(gè)贊
if(exists(select * from 關(guān)鍵字表 where 條件))
begin
end
else
begin
select * from 地區(qū)表
end

長(zhǎng)風(fēng)秋雁
TA貢獻(xiàn)1757條經(jīng)驗(yàn) 獲得超7個(gè)贊

胡子哥哥
TA貢獻(xiàn)1825條經(jīng)驗(yàn) 獲得超6個(gè)贊
ALTER PROCEDURE [dbo].[P_test] -- Add the parameters for the stored procedure here -- Add the parameters for the stored procedure here @C_Conditon varchar(50) AS BEGIN if(exists(select * from Table where C_Order=@C_Conditon)) return; else select * from Table ; -- Insert statements for procedure here END
樓上的回復(fù)都很好。。
- 5 回答
- 0 關(guān)注
- 510 瀏覽
添加回答
舉報(bào)
0/150
提交
取消