Like Dali, I haven't used MySQL for a while - but I'm pretty sure the below
will work in PostgreSQL so could be worth a shot in MySQL.

SELECT
        *
FROM
        table1
        LEFT JOIN table2 ON (table2.product_id = table1.product_id)
WHERE
        length(table2.blob) > 0
        AND table1.product_id='$id' --OPTIONAL
;

That would mean that you don't need to worry about filtering out the zero
length fields in PHP if there is the possibility of an empty blob rather
than a NULL blob.

Thanks,
Nathan
Web Controlled Robot Arm and Beetle
http://www.kennedytechnology.com


-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf
Of Dalibor Andzakovic
Sent: Monday, 3 November 2008 11:02 p.m.
To: [email protected]
Subject: [phpug] Re: MySQL question #2


SELECT * FROM table1 LEFT JOIN table2 ON (table1.productid =
table2.productid) WHERE table1.productid = '$id'

Will get all the records from table1 and matching fileds from table 2. Then
in you php code you can do

While($row = mysqli_fetch_assoc()){
        If(sizeof($row['blob'] > 0){
                // do something with blob
        }
}

HTH

Dali

P.S. Been a while since I had to use MySQL so pardon any errors



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