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
> -----Original Message-----
> From: [email protected] [mailto:[EMAIL PROTECTED] On
> Behalf Of Michael
> Sent: Monday, 3 November 2008 22:41
> To: [email protected]
> Subject: [phpug] MySQL question #2
>
>
> Thank you to the people who posted solutions to the last question. :-)
>
> To expand on this, is it possible with MySQL to do the following-
>
> I have two tables, both with 'productid' as the primary field.
>
> I need retrieve a few fields from table 1, but I only need to know if a
> line
> exists and has a BLOB size larger then 0, in table 2.
>
> (By way of explanation, table 1 has product information and table 2 has
> product images - both share the same primary field).
>
> If that line exists and with content I want to activate code within a
> PHP 'if'
> statement, however I don't actually want to retrieve the field.
>
> And I'd like to do all of this in 1 SQL statement.
>
> Relevant fields within tables-
>
> table 1 (product info)
> - productid (int primary)
> - title_1 (varchar)
> - title_2 (varchar)
> - title_3 (varchar)
>
> table 2 (images)
> - productid (int primary)
> - pic (blob)
>
>
--~--~---------~--~----~------------~-------~--~----~
NZ PHP Users Group: http://groups.google.com/group/nzphpug
To post, send email to [email protected]
To unsubscribe, send email to
[EMAIL PROTECTED]
-~----------~----~----~----~------~----~------~--~---