1、我用Access做了三个表,一个表是艺术家表,一是艺术家作品表,还有一个是他们间的对应表,我想写一SQL语句,读取每个艺术家的姓名和其的一幅作品,不知要怎么写?
我写的是:select a.ArtistID,a.ArtistName,c.img from Artist a,ArtPro b,Production c where b.ProID=c.ProID and a.ArtistID=b.ArtistID
可是出来的是所有的作品!
2、还有一个问题:
我想实现点击小图看大图的效果,
<asp:hyperlink id="HyperLink5" runat="server" Target="_blank" NavigateUrl='../<%#DataBinder.Eval(Container.DataItem, "img")%>'>
<IMG height=138 src='Production/<%#DataBinder.Eval(Container.DataItem, "img")%>' width="112" border=0>
</asp:hyperlink>
这样写的链接为 http://localhost/ts1/Production/<%#DataBinder.Eval(Container.DataItem, "img")%>
要改哪儿才可以实现呢?
我写的是:select a.ArtistID,a.ArtistName,c.img from Artist a,ArtPro b,Production c where b.ProID=c.ProID and a.ArtistID=b.ArtistID
可是出来的是所有的作品!
2、还有一个问题:
我想实现点击小图看大图的效果,
<asp:hyperlink id="HyperLink5" runat="server" Target="_blank" NavigateUrl='../<%#DataBinder.Eval(Container.DataItem, "img")%>'>
<IMG height=138 src='Production/<%#DataBinder.Eval(Container.DataItem, "img")%>' width="112" border=0>
</asp:hyperlink>
这样写的链接为 http://localhost/ts1/Production/<%#DataBinder.Eval(Container.DataItem, "img")%>
要改哪儿才可以实现呢?
inner join a on a.ArtistID=b.ArtistID
inner join b on b.ProID=c.ProID
where c.proid=你要查的值
<IMG height=138 src='<%#DataBinder.Eval(Container.DataItem,"img","Production/{0}")%>' width="112" border=0>
</a>
select a.id,a.艺术家,b.作品 from 艺术家 inner join 作品表 on a.id=b.pid where a.id in(select top 1 b.pid from 艺术家 order by pid desc\asc)
楼主试试
string sqltpxw=@"select ysj.id,ysj.name
(select top 1 mc from zp where ysj.id=ysjid order by id asc)
as zp from ysj";* 表示艺术家基本信息
(select top 1 mc from zp where ysj.bh=ysjbh order by bh asc) 查找对应艺术家的一幅作品
ysj 艺术家表
zp 作品表
from Artist a
inner join ArtPro b on a.ArtistID=b.ArtistID
inner join Production c on b.ProID=c.ProID
group by a.ArtistID,a.ArtistName
from Artist a
inner join ArtPro b on a.ArtistID=b.ArtistID
inner join Production c on b.ProID=c.ProID
group by a.ArtistID,a.ArtistName,imgc.
,( select ArtistID,min(ProID) as ProID from ArtPro group by ArtistID) b
,Production c
where b.ProID=c.ProID and a.ArtistID=b.ArtistID
*****************************************************************************
欢迎使用CSDN论坛阅读器 : CSDN Reader(附全部源代码)
http://www.cnblogs.com/feiyun0112/archive/2006/09/20/509783.html
select a.ArtistID,a.ArtistName,(select top 1 c.img from ArtPro b,Production c where b.ProID=c.ProID and a.ArtistID=b.ArtistID) as img from Artist a
select a.ArtistID,a.ArtistName,min(c.img) from Artist a,ArtPro b,Production c where b.ProID=c.ProID and a.ArtistID=b.ArtistID
group by a.ArtistID,a.ArtistName