sql server 2008 - how to select one image of a object stored in another table -


the question may easy product table in sql

id, name, . . .  productimage id,productid,image 

select image in select query of product need first/last image of product1,first/last image of product2 etc

that is

select product.id,product.name,(select top(1)image productimage productimage.productid=product.id)as image product 

this query gives me first image of first product in product list

thank you

try this,maybe useful:

select product.id,product.name, (select top (1) image productimage productimage.productid=product.id order productimage.id asc)as firstimage , (select top (1) image productimage productimage.productid=product.id order productimage.id desc) lastimage product 

Comments

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -