更新的代码
$office = $this->session->userdata('department');
$query = "SELECT `doc`.`id`, `doc`.`barcode`, `doc`.`sub`, `doc`.`source_type`, `doc`.`sender`, `doc`.`address`, `doc`.`description`, `doc`.`receipient`, `doc`.`status`, DATE_FORMAT(`doc`.`datetime_added`, '%m/%d/%Y-%h:%i %p') as datetime_added,
(SELECT GROUP_CONCAT(`tag`) FROM `tags` WHERE `tags`.`documentId` = `doc`.`id` GROUP BY `tags`.`documentId`) as `tags`
FROM `documents` AS `doc`
JOIN `transactions` AS `trans` ON `doc`.`id` = `trans`.`document_id`
JOIN `trackers` AS `track` ON `doc`.`id` = `track`.`document_id`
WHERE `doc`.`status` = 'Processing'
AND `track`.`action` = '1')
AND `track`.`location` = '$office'
ORDER BY `doc`.`id` DESC";
$go = $this->db->query($query)->result_array();
var_dump($go); exit();
我要做的是显示我们办公室中所有正在处理且有操作1的文档。文件可能有诸如备忘录、请求、财务等标签。输出不正确,没有显示我们办公室的所有记录。我认为where子句有问题?在我的代码里什么是罪魁祸首?
2条答案
按热度按时间1aaf6o9v1#
通过删除围绕1的单引号来更新查询:
cgh8pdjw2#