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 |
|
curry
Starting Member
14 Posts |
Posted - 2008-10-07 : 09:30:03
|
| Hi I have an issue with the following statementselect products.productid, products.name, tbl_media.media_namefrom products inner join tbl_media on products.productid = tbl_media.productidwhere products.catcode=26 order by products.productid ascReturnsID---Name---Image575 Widget Widget_img1575 Widget Widget_img2575 Widget Widget_img3But I need to put a single record for each product, not a single record for each media_name. ID---Name---Image575 Widget Widget_img1I've tried SELECT DISTINCT but the join messes that up. I think I need to use a subquery but I'm still struggling with it. Thank you in advance. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-10-07 : 09:37:55
|
| [code]select products.productid, products.name, min(tbl_media.media_name) as media_namefrom products inner join tbl_media on products.productid = tbl_media.productidwhere products.catcode=26 group by products.productid, products.nameorder by products.productid asc[/code] |
 |
|
|
curry
Starting Member
14 Posts |
Posted - 2008-10-07 : 09:52:34
|
| Thank you sir. |
 |
|
|
|
|
|