求一联合查询的sql语句

[复制链接]
查看11 | 回复3 | 2013-5-7 23:20:19 | 显示全部楼层 |阅读模式
--用存储过程可以么?create proc proc_select@a int,@b intasbeginselect * from abc "abc_1"
where fid = @b
and exists
(
select * from abc "abc_2"
where "abc_1".id = "abc_2".id
and "abc_2".fid = @a
)endgoexec proc_select 1, 0--欢迎追问...
回复

使用道具 举报

千问 | 2013-5-7 23:20:19 | 显示全部楼层
select * from abc where fid = (select (case count(*) when 0 then 0 else 1 end) from abc where fid = '1')...
回复

使用道具 举报

千问 | 2013-5-7 23:20:19 | 显示全部楼层
create proc proc_test@a int asbeginif not exists (select * from abc where fid = @a)
select * from abc where fid=0end...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行