Я хочу найти дубликаты записей в таблице.
public function duplicate_records() {
$sql = " select * from tbloptions where name in (select name from tbloptions group by name having COUNT(*)>1)";
$result = $this->db->query($sql);
$row = $result->result();
echo '<pre>';
print_r($row);
}
Я написал приведенный выше запрос и получаю следующий вывод: -
Array
(
[0] => stdClass Object
(
[id] => 1
[name] => dateformat
[value] => d-m-Y|%d-%m-%Y
[autoload] => 1
)
[1] => stdClass Object
(
[id] => 2
[name] => companyname
[value] => 01Crypto.com
[autoload] => 1
)
[2] => stdClass Object
(
[id] => 316
[name] => dateformat
[value] => d-m-Y|%d-%m-%Y
[autoload] => 1
)
[3] => stdClass Object
(
[id] => 317
[name] => dateformat
[value] => d-m-Y|%d-%m-%Y
[autoload] => 1
)
[4] => stdClass Object
(
[id] => 318
[name] => companyname
[value] => 01Crypto.com
[autoload] => 1
)
)
Итак, на выходе [name] => dateformat
приходит 3 раза, а [name] => companyname
- 2раз.
Редактировать: -
Я хочу следующий вывод: -
[0] => stdClass Object
(
[id] => 1
[name] => dateformat
[value] => d-m-Y|%d-%m-%Y
[autoload] => 1
)
[2] => stdClass Object
(
[id] => 316
[name] => dateformat
[value] => d-m-Y|%d-%m-%Y
[autoload] => 1
)
[3] => stdClass Object
(
[id] => 317
[name] => dateformat
[value] => d-m-Y|%d-%m-%Y
[autoload] => 1
)
[1] => stdClass Object
(
[id] => 2
[name] => companyname
[value] => 01Crypto.com
[autoload] => 1
)
[4] => stdClass Object
(
[id] => 318
[name] => companyname
[value] => 01Crypto.com
[autoload] => 1
)
любая помощь будет оценена.