On Fri, 02 Oct 2009 10:26:30 Antoine S. wrote:
> Hi,
>
> If you dont really need the count of picture and you just need to know
> if a picture exist or not for the product,
> the subquery is useless, you could use :
> SELECT   product.productid,
>          product.title,
>          product.added,
>          picture.w AS `width`,
>          picture.h AS `height`,
>          picture.m AS `mime`,
>          picture.id  #or: IF(picture.id IS NULL, 'NO_PICTURE',
> 'PICTURE')
> FROM     `product`
>          LEFT JOIN `picture`
>            ON product.productid = picture.productid
>                   AND picture.pic != ''
> WHERE    categoryid = '$categoryid'
>          AND `categoryid` IN $catlist
>          AND `display` = '1'
> ORDER BY `title` ASC
> LIMIT    $start,$products

Thanks. I have the following questions:

1. Is this suggested query more efficient or is it just another way of doing 
things? Is there a reason why it's better please?

2. What will it return if picture exists, or no picture exists? I need a 
variable to run a PHP if statement (run display picture HTML code or not)

Thanks :-)

--~--~---------~--~----~------------~-------~--~----~
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