Home > PHP Framework > ThinkPHP > How to query duplicate database in thinkphp

How to query duplicate database in thinkphp

藏色散人
Release: 2022-12-13 09:51:01
Original
1636 people have browsed it

Thinkphp method to query duplicate databases: 1. Instantiate the data table through "$test_data = M('hot');"; 2. Use "testdata>Distincttrue)->field(descriprion')- >orderdescription desc->select" method or use the group method to remove duplicates.

How to query duplicate database in thinkphp

The operating environment of this tutorial: Windows 7 system, ThinkPHP version 5, Dell G3 computer.

thinkphp How to query duplicate databases?

thinkphp database duplication checking method

$test_data = M('hot');//实例化数据表
$data=$testdata>Distincttrue)->field(descriprion')->orderdescription desc->select:
//利用distinct方法去重
$data=$test_data->group("description')->order('description desc')->select();
//利用group方法去重 
dump($data);
Copy after login

For two deduplication methods:

Use distinct to deduplicate, simple and easy to use, but it can only be used for a single field Heavy, and the final result is only the fields with the duplicate removed, and the actual application value is not particularly great.

Using group to remove duplication, the final display result is all fields, and a single field is deduplicated. The effect is good, but the final display result is sorted according to the first field except for the deduplication field. May still need to be processed.

Recommended learning: "thinkPHP Video Tutorial"

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template