Question : Select TOP 1 in an INNER JOIN

Hi,

I have tow tables, one for properties and one for images, I want to return all the properties for a user and the top image from the related images table.

I have the code below, but it does not return any records, but I know there are some.

Any help gratefully received.

Thanks
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
SELECT 
		tp.propID, tp.AddedDate, tp.PropType, tp.NoBedrooms, tp.ShortDesc, tp.City, tp.ReleaseDate, 
		 ti.binaryImage
		FROM dbo.tbl_Properties tp
		INNER JOIN dbo.tbl_propertyImages ti On tp.propID = ti.PropID
		WHERE ti.PropID IN (select Top 1 ti.binaryImage FROM dbo.tbl_PropertyImages ti WHERE tp.AddedBy = @UserID)
		AND
		tp.AddedBy = @UserID

Answer : Select TOP 1 in an INNER JOIN

sorry remove  ti.binaryImage from code..
1:
2:
3:
4:
SELECT  tp.propID, tp.AddedDate, tp.PropType, tp.NoBedrooms, tp.ShortDesc, tp.City, tp.ReleaseDate,  
                 (select Top 1 ti.binaryImage FROM dbo.tbl_PropertyImages ti WHERE tp.AddedBy = @UserID AND tp.propID = ti.PropID)  as binaryImage 
                FROM dbo.tbl_Properties tp 
                WHERE tp.AddedBy = @UserID
Random Solutions  
 
programming4us programming4us