news表记录 files表记录
id title content id newsid filename
1 a 略 1 1 aaaa
2 b 略 2 1 bbbb
3 c 略 3 2 cccc
我只要得到结果 1 a aaaaa
2 b ccccc
4 个解决方案
#1
select a.id,a.title,(select min(filename) from files b where a.id=b.newsid)
from news a
from news a
#2
http://community.csdn.net/Expert/topic/5400/5400771.xml?temp=.5377466
#3
http://community.csdn.net/Expert/topic/5089/5089261.xml?temp=.7907068
#4
如果是隨便取一個filename的話
Select
A.id,
A.title,
Min(B.[filename]) As [filename]
From
A
Inner Join
B
On A.id = B.newsid
Group By
A.id,
A.title
Select
A.id,
A.title,
Min(B.[filename]) As [filename]
From
A
Inner Join
B
On A.id = B.newsid
Group By
A.id,
A.title
#1
select a.id,a.title,(select min(filename) from files b where a.id=b.newsid)
from news a
from news a
#2
http://community.csdn.net/Expert/topic/5400/5400771.xml?temp=.5377466
#3
http://community.csdn.net/Expert/topic/5089/5089261.xml?temp=.7907068
#4
如果是隨便取一個filename的話
Select
A.id,
A.title,
Min(B.[filename]) As [filename]
From
A
Inner Join
B
On A.id = B.newsid
Group By
A.id,
A.title
Select
A.id,
A.title,
Min(B.[filename]) As [filename]
From
A
Inner Join
B
On A.id = B.newsid
Group By
A.id,
A.title