Home > PHP Framework > ThinkPHP > Thinkphp uses join table query method

Thinkphp uses join table query method

angryTom
Release: 2020-03-24 11:57:43
forward
4538 people have browsed it

This article introduces the method of using join table query in Thinkphp. It has certain reference value. I hope it will be helpful to all friends who are learning thinkphp!

Thinkphp uses join table query method

Thinkphp uses join table query method

Multiple table join query:

$user = M('user');
$b_user = M('b_user');
$c_user = M('c_user');
$list = $user->alias('user')->where('user.user_type=1')
    ->join('b_user as b on b.b_userid = user.user_id')
    ->join('c_user as c on c.c_userid = b.b_userid')
    ->order('b.user_time')
    ->select();
Copy after login

$user table The user_id is equal to the b_userid of the $b_user table;

The c_userid of the $c_user table is equal to the b_userid of the $b_user table;

Recommended learning: thinkphp tutorial

The above is the detailed content of Thinkphp uses join table query method. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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
Latest Issues
Why thinkphp has better performance than laravel?
From 1970-01-01 08:00:00
0
0
0
ThinkPHP Why use composer?
From 1970-01-01 08:00:00
0
0
0
thinkphp versions supported by php6
From 1970-01-01 08:00:00
0
0
0
thinkphp upload files
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template