2013-07-26 85 views
1

我有3個表名REGISTERMASTER,FRIEND和UPLOAD。子查詢返回單個值以上

我想獲得所有上傳的上傳where UPLOAD.id= session["id"]或其friendid和REGISTERMASTER具有所有id的細節,所以我想獲得那些UPLOAD.id的細節。

我寫這篇文章的查詢

select * from upload left join registermaster on upload.id=registermaster.id where upload.id in ('"+Session["id"]+"', select userid from friend where frienid='"+Session["id"]+"' and approve='"+true+"') 

,但有子查詢返回多個值的誤差

請幫助

+0

有多少行是這個'(frienid ,批准='真')'值對?最大。一排只有一行;零,一個或多個行? –

回答

0

使用select top 1 userid from friend where frienid='"+Session["id"]+"' and approve='"+true+"')