Using a column from a JOINed table in a CONCAT() expression with CodeIgniter's query builder
04:16 29 Jun 2021

I'm using CodeIgniter and I'm having difficulty trying to figure this out.

So I have this query that includes a joined table, then I need the ua_number column from that joined table for concatenation for the image column. The ua_number returns a value no problem but when I append it to the concatenation, it doesn't work as planned.

Here's the code

$this->db
    ->select(" 
        p.promotion_id,
        p.partner_id,
        ps.ua_number AS ua_number,
        description,
        start_date,
        end_date,
        date_created,
        CONCAT('https://s3-ap-southeast-1.amazonaws.com/paychatph-assets/pcb_updates/promotions/', MD5(p.promotion_id), '/', (ps.ua_number), '.jpeg')  AS image
    ")
    ->from('promotions p')
    ->join('partners ps' , 'p.partner_id = ps.partner_id' , 'INNER');
php codeigniter join concatenation query-builder