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 |
|
TazMania
Yak Posting Veteran
63 Posts |
Posted - 2005-01-13 : 05:44:07
|
Hi,I have 2 tables One called link.LinkID,intLinkDate,datetimeLinktext,varcharLink,ntextLinkCat,varcharLinkHits,intand the other LinkCatLinkCatID,intLinkCatDate,datetimeLinkCatText,varcharI looking for a way to write a select clause something like this.SELECT Link.LinkID,Link.LinkDate,Link.LinkText,Link.Link,Link.LinkCatID,Link.LinkHits,LinkCat.LinkCatID,LinkCat.LinkCatText FROM Link LEFT OUTER JOIN LinkCat ON Link.LinkCatID=LinkCat.LinkCatID GROUP BY Link.LinkCatIDBut I can't it to work properly.Any assistence would be much appreciated !Best regardsTaz :)Best regardsTaz  |
|
|
Stoad
Freaky Yak Linguist
1983 Posts |
Posted - 2005-01-13 : 07:20:30
|
| SELECTLink.LinkID, Link.LinkDate, Link.LinkText, Link.Link, Link.LinkHits,LinkCat.LinkCatID, LinkCat.LinkCatText FROM Link LEFT OUTER JOIN LinkCat ON Link.LinkID=LinkCat.LinkCatID--- GROUP BY Link.LinkCatID -- why "group by"?and I don't see field LinkCatID in "left" table Link. |
 |
|
|
TazMania
Yak Posting Veteran
63 Posts |
Posted - 2005-01-13 : 07:36:42
|
Thx for the reply :)Wups.. my mistake LinkCat in table Link should be LinkCatID. :)And the reason for group by is that the Link table can have several link under the same group, and instead of code this in asp, I just figured it would run much smoother if I would let the sql server handle this..Data example from link tableLinkID - LinkDate - LinkText - Link - LinkCatID - LinkHits1 - 13.01.05 - test1 link - http://www.test1.com - 1 - 02 - 10.01.05 - test2 link - http://www.test2.com - 1 - 0Data example from LinkCatLinkCatID - LinkCatDate - LinkCatText1 - 09.01.05 - Test catBest regardsTaz |
 |
|
|
|
|
|
|
|