Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
jamesthank
Starting Member
3 Posts |
Posted - 2010-07-31 : 07:54:29
|
Hi friends, I'm new in this fourm, I have two tables named ImgMain & ImgSub.ImgMain table contain the feilds..MId (primary key)MImgPathEventNameImgSub table contain the feilds..SIdMIdSubImgPath (Here MId is used as foreign key in ImgSub )I want to select MId,MImagePath,Eventname form the first table(ImgMain) and count of MId from the second table(ImgSub).How can I select in a single query? Could you pls help me to slove?...Cheers,Thanks a ton.James. |
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-07-31 : 08:04:36
|
A quick solution will be:select MId,MImagePath,Eventname,(select count(*) from ImgSub s where s.MId = m.MId) as cnt_Subfrom ImgMain m No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|
|