distinct(true)->select();" method."/> distinct(true)->select();" method.">

Home >PHP Framework >ThinkPHP >How to remove duplicate values ​​in thinkphp

How to remove duplicate values ​​in thinkphp

藏色散人
藏色散人Original
2022-01-06 15:20:514300browse

Thinkphp method to remove duplicate values: 1. Open the corresponding TP file; 2. Use the "$result = M("order")->distinct(true)->select();" method Just remove duplicate data.

How to remove duplicate values ​​in thinkphp

The operating environment of this article: Windows7 system, ThinkPHP5 version, Dell G3 computer.

How to remove duplicate values ​​in thinkphp?

ThinkPHP Remove duplicate data and merge duplicate fields

1. Remove duplicate data

distinct

$result = M("order")->distinct(true)->select();

2. Merge Duplicate fields

group

$result = M("user")->group("name")->select()

For example: name is repeated and only one field is displayed

Recommended learning: "The latest 10 thinkphp Video tutorial

The above is the detailed content of How to remove duplicate values ​​in thinkphp. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn