我有一个生成此查询的codeigniter代码:
SELECT other_categories.id as main_id, other_categories.name as main_full_name,
category_type as policy_no, GROUP_CONCAT(CONCAT_WS(" ",
other_cat_details.first_name,
other_cat_details.middle_name, other_cat_details.last_name)) as
other_full_name FROM
(`other_categories`) LEFT JOIN `other_category_details` ON
`other_category_details`.`other_category_id` = `other_categories`.`id` LEFT
JOIN `users` as other_cat_details ON `other_cat_details`.`id` =
`other_category_details`.`user_id` WHERE `category_type` = '2'
GROUP BY `main_id` ORDER BY `name` ASC LIMIT 10
有没有办法可以添加其他查询,我可以在另一个查询中过滤我的数据other_full_name
,如变量$name_entered
?
在分组之前添加:
$this->db->like('other_full_name', $name);
生成:未知列' other_full_name'在' where子句'
请注意,这是用于通配符搜索结果,该结果是查询建议的一系列字符。 having子句将识别other_full_name。我想知道我们是否可以添加'喜欢'它。
非常感谢任何帮助。请要求澄清。
答案 0 :(得分:0)
您可以使用having
子句:
having(other_full_name = $name)
在codeigniter中,我认为它会是:
$this->db->having('other_full_name like $name')
或某些类似的变体