Thinkphp multi-table query has the perfect solution when two tables have the same fields repeated

不言
Release: 2023-03-30 12:18:02
Original
3330 people have browsed it

The following is a perfect solution for thinkphp multi-table query where the same fields are repeated in two tables. The content is quite good, so I will share it with you now and give it as a reference.

Framework: thinkphp

Version: 3.2.3

Content: Query statement

Solution to the problem: Duplicate field problem

$Data = M('a')->where($where)
  ->Field('a.name as aname,b.name as uname,a.*')
  ->join('b on b.jb_id=a.id')
  ->order('a.id desc')
  ->select();
Copy after login

Explanation: a.* Query all fields of table a

a .name as aname Convert the name repeated field in table a to aname

Related recommendations:

Analysis of form token errors and solutions under ThinkPHP

Solution to the temporary folder not found when uploading to PHP

The above is the detailed content of Thinkphp multi-table query has the perfect solution when two tables have the same fields repeated. 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