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();
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!