【发布时间】:2019-06-07 01:18:40
【问题描述】:
$this->db->select('*');
$this->db->from('table1');
$where = "tag = '".$tag."'";
$this->db->where($where);
$query1 = $this->db->get();
$result1 = $query1->num_rows();
$this->db->select('*');
$this->db->from('table2');
$where = "tag = '".$tag."'";
$this->db->where($where);
$query2 = $this->db->get();
$result2 = $query2->num_rows();
$result = $result1+$result2;
return $result;
在这个问题中,我有两个表table1 and table2,两者的表结构相同。现在,我想计算行数。现在,它显示了错误的计数数据。如果tag 数据存在于第一个表中,则它计入1,如果tag 数据存在于两个表中,则它计入2。那么,我该怎么做呢?请帮帮我。
谢谢
【问题讨论】:
标签: php codeigniter mysqli