Barry Galbraith Wrote:
-------------------------------------------------------
> Close, but not quite.
> Use a LEFT JOIN to get every row of the table on
> the LEFT side of the JOIN, and only the matching
> rows from the table on the right side of the JOIN.
>
> SELECT tblForSaleItems.id,
> tblForSaleItems.`desc`, -- desc is a reserved
> d word so must be enclosed in back ticks. Save
> yourself a LOT of grief and use a different name
> for the field.
> tblForSaleImages.imagePath
> FROM tblForSaleItems
> LEFT JOIN tblForSaleImages
> ON tblForSaleItems.id =
> tblForSaleImages.FK_ForSaleItems
> WHERE tblForSaleImages.primaryImage = 1;
>
Thanks Barry, Almost there.
I can get the join to work without the where clause, but the where clause necessitates a corresponding value in the tblForSaleImages table, so I'm not getting items without images.
I have tried adding an OR operator in the where statement like "WHERE tblForSaleImages.primaryImage = 1 or NULL but not successful.
Is this a case for a sub-query maybe?