我有一个代码点火器代码,它产生这个查询:
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);
生成:"where子句"中的未知列"other_full_name"
请注意,这是用于通配符搜索的结果,该结果是查询所建议的一系列字符。haven子句将识别otherfullname。我想知道我们是否可以在上面加上"赞"。
非常感谢您的帮助。请澄清。
您可以使用having
子句:
having(other_full_name = $name)
在代码点火器中,我认为它将是:
$this->db->having('other_full_name like $name')
或一些类似的变体