现在有三个表,WD_Category,WD_Image和WD_WdjbxxWD_Category表结构:
id 主键
categories
WD_Image表结构:
id 主键
image
path
documentid 外键,与WD_Wdjbxx中的id对应
WD_Wdjbxx表结构:
id 主键
author
body
uploadby
categoryid 外键,与WD_Category表中的id对应现在我想查询三个表,通过WD_Wdjbxx的id得到WD_Wdjbxx中的author,body,uploadby,以及categoryid对应的categories和WD_Image中documentid为该id的image和path,共显示6个字段,请问该如何编写该存储过程?
id 主键
categories
WD_Image表结构:
id 主键
image
path
documentid 外键,与WD_Wdjbxx中的id对应
WD_Wdjbxx表结构:
id 主键
author
body
uploadby
categoryid 外键,与WD_Category表中的id对应现在我想查询三个表,通过WD_Wdjbxx的id得到WD_Wdjbxx中的author,body,uploadby,以及categoryid对应的categories和WD_Image中documentid为该id的image和path,共显示6个字段,请问该如何编写该存储过程?
select author,body,uploadby,categoryid,path,image
from WD_Category a,WD_Image b,WD_Wdjbxx c
where a.id=c.categoryid and b.documentid =c.id and c.id='某某'
@id1 char(6)
asselect a.author,a.body,a.uploadby,c.categoryid,b.path,b.image
from WD_Category a,WD_Image b,WD_Wdjbxx c
where a.id=c.categoryid and b.documentid =c.id and c.id=@id1