当前位置:网站首页>Thinkphp5 multi table associative query method join queries two database tables, and the query results are spliced and returned
Thinkphp5 multi table associative query method join queries two database tables, and the query results are spliced and returned
2022-07-06 22:47:00 【Dehong eye inserting demon king】
Database only
Want to achieve :
Code up :
public function demo()
{
// With shop Main table
$res = Db::table('shop')
->alias("a") // Take an alias
// And shop_class Tables are associated , The name i, also a Tabular shop_class Field equals i Tabular class_code Field
// Table 1 and table 2 are the same :'a.shop_class = i.class_code'
->join('shop_class i', 'a.shop_class = i.class_code')
->field('a.id,a.shop_name,a.shop_price,a.shop_details,i.class_name,a.shop_src,a.shop_xq_src1,a.shop_xq_src2,a.shop_xq_src3,a.good_unit,a.good_parameter,a.good_specs_code')
// Query required fields field()
->select();
//->paginate(10);// If you need to add this paragraph by page
var_dump($res);
}
边栏推荐
- DR-Net: dual-rotation network with feature map enhancement for medical image segmentation
- Void keyword
- Motion capture for snake motion analysis and snake robot development
- Config:invalid signature solution and troubleshooting details
- Extern keyword
- case 关键字后面的值有什么要求吗?
- MySQL----初识MySQL
- Slide the uniapp to a certain height and fix an element to the top effect demo (organize)
- 2022-07-05 stonedb sub query processing parsing time analysis
- memcached
猜你喜欢
MySQL----初识MySQL
剑指offer刷题记录1
Sword finger offer question brushing record 1
Aardio - does not declare the method of directly passing float values
Netxpert xg2 helps you solve the problem of "Cabling installation and maintenance"
Mysql database basic operations DML
Clip +json parsing converts the sound in the video into text
Unified Focal loss: Generalising Dice and cross entropy-based losses to handle class imbalanced medi
如何用程序确认当前系统的存储模式?
Method of canceling automatic watermarking of uploaded pictures by CSDN
随机推荐
专为决策树打造,新加坡国立大学&清华大学联合提出快速安全的联邦学习新系统
UE4 blueprint learning chapter (IV) -- process control forloop and whileloop
How big is the empty structure?
Unified Focal loss: Generalising Dice and cross entropy-based losses to handle class imbalanced medi
Is there any requirement for the value after the case keyword?
Designed for decision tree, the National University of Singapore and Tsinghua University jointly proposed a fast and safe federal learning system
The difference between enumeration and define macro
「小程序容器技术」,是噱头还是新风口?
volatile关键字
Matlab tips (27) grey prediction
服务器的系统怎么选者
uniapp设置背景图效果demo(整理)
UVa 11732 – strcmp() Anyone?
Void keyword
General implementation and encapsulation of go diversified timing tasks
[untitled]
UE4蓝图学习篇(四)--流程控制ForLoop和WhileLoop
extern关键字
Volatile keyword
memcached