GROUP_CONCAT on image blob?

user796443

I remember group_concat in mysql has character limit, that can be lifted before query. But even without this character limit, can I use it to have a list of images?

There are two tables,

Table #1, contains list of customers Table #2, contains attachments (img/blob)

There are more rows per customer in second table. I would like to have 1 query that selects customers and attachment. I was going to use group_concat and than explode(',') in php

 SELECT wp_appointments.id,
        wp_appointments.full_name,
        wp_appointments.primary_email,
        wp_appointments.contact_tel,
        wp_appointments.appointment_date,
        wp_appointments.appointment_status,
        wp_appointments.payment_status,
        GROUP_CONCAT(wp_appointments_attch.id),
        wp_appointments_attch.attachement,
        wp_appointments_attch.attach_type
      FROM wp_appointments
RIGHT JOIN wp_appointments_attch
        ON wp_appointments_attch.appointment_id = wp_appointments.id
     WHERE service_type = 'c'
  GROUP BY wp_appointments.id
Bill Karwin

Yes, you can use GROUP_CONCAT() on blobs, but you may not be able to use explode() on the resulting concatenated images to get the individual images out.

It's likely that the byte value 0x2C (same as ASCII for ,) occurs by coincidence within a given image blob data. So if you rely on 0x2C as the separator between images, your explode() will accidentally split the image that contains that byte.

No matter what other separator you choose for your GROUP_CONCAT(), that separator might occur in the sequence of bytes of image data.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related