Postgresql 查询substr Codeigniter的位置
我必须检查数据库中字符串的两个字符。 这是我的代码,但它不起作用Postgresql 查询substr Codeigniter的位置,postgresql,codeigniter,where,Postgresql,Codeigniter,Where,我必须检查数据库中字符串的两个字符。 这是我的代码,但它不起作用 function getby_substr() { $query = $this->db ->where('substr(ipv6, 4,2 )', 'c1') ->get('computer_information'); if ($query->num_rows() > 0) { r
function getby_substr() {
$query = $this->db
->where('substr(ipv6, 4,2 )', 'c1')
->get('computer_information');
if ($query->num_rows() > 0) {
return $query->result();
}
return array();
}
谢谢,希望这对您有所帮助:
带where子句
带like子句
更多信息:使用如下常规查询尝试where条件:$this->db->whereSUBSTRipv6,4,2='c1';关于列和值匹配的更多详细信息谢谢你,布拉格!
/*replace column_name with your table field name*/
$query = $this->db
->where('column_name', SUBSTRING(ipv6, 2, 5))
->get('computer_information');
$query = $this->db
->like('column_name', SUBSTRING(ipv6, 2, 5))
->get('computer_information');