I have two tables and I have to join it. table structures are
tblproducts –> id(int,pk), name(varchar)
tblphotos —> id(int,pk), productid(int,fk), photo(varchar), display_order(int)
There can be more than one photos for each product, I need to get one photo with lowest display_order.
I need, tblproducts.id, tblproducts.name, tblphotos.photo(photo with least display_order) also I need to get the whole list as tblproducts.id in ascending order.
EDIT: Oppss! I didn’t see mysql tag. This is for MSSQL by the way.
Yes this query looks like repeating. I should delete
Whereclause.