Hi all,
I've spent a few hours staring at this piece of code. Fresh eyes please!
Here is a shortened version of the query:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL
server version for the right syntax to use near
'FROM (`requests` c) JOIN `inventory` d ON `d`.`listing_seq_no` = `c' at line 7
SELECT DISTINCT `c`.`req_id`, `u`.`user_id`, `u`.`org_name`,
CONCAT_WS(' ', `l`.`strength`, `l`.`unit)` as dos, `c`.`quantity` AS quantity1,
(SELECT sum(quantity) from inventory d2
WHERE d2.listing_seq_no = c.listing_seq_no
) as inv_total,
FROM (`requests` c)
JOIN `inventory` d
ON `d`.`listing_seq_no` = `c`.`listing_seq_no`
JOIN `listings` l
ON `l`.`listing_seq_no` = `c`.`listing_seq_no`
EDIT: Original CodeIgniter Code snippet:
$this->db->select ( "c.req_id,
u.user_id,
u.org_name,
l.tradename as name,
CONCAT_WS(' ', l.strength, l.unit) as dos,
);