Statement (to obtain a paginated list of products)

SELECT product.productid,product.title,product.added,picture.w AS `width`,
picture.h AS `height`,picture.m AS `mime`, (SELECT count(`pic`) FROM `picture` 
WHERE picture.productid=product.productid AND picture.pic !='') AS `pcx` FROM 
`product` LEFT JOIN `picture` ON product.productid=picture.productid
WHERE categoryid='$categoryid' AND `categoryid` IN $catlist AND `display`='1' 
ORDER BY `title` ASC LIMIT $start,$products

Tables:
'product' - product details
'picture' - pictures stored in database as binary

It does a subquery to astertain if a picture exists (else sets a NULL field so 
the front end application skips the display picture code), though I am 
wondering what is the LEFT JOIN required for?

We aren't actually trying to retrieve the picture BLOB in this query, just 
checking if it exists.

Michael

--~--~---------~--~----~------------~-------~--~----~
NZ PHP Users Group: http://groups.google.com/group/nzphpug
To post, send email to [email protected]
To unsubscribe, send email to
[email protected]
-~----------~----~----~----~------~----~------~--~---

Reply via email to