当前位置:网站首页>DB queries the database, merges two unrelated tables, adds non-existent fields, and assigns default values
DB queries the database, merges two unrelated tables, adds non-existent fields, and assigns default values
2022-06-29 21:01:00 【Xiang Yu it】
demand : There are two unrelated tables in the two databases , I need to merge them , And in order2 Add nonexistent product_name Field , And give default values
$product_name = ' The default value is ';
$news = DB::table("guild_pay.order1")
->where('status', '=', 1)
->selectRaw('product_name','order_no','money','create_time');
$res = Db::table('guild_pay.order2')
->where('status', '=', 1)
->union($news)
->selectRaw('IFNULL(null, ?) as product_name, order_no, money, create_time', [$product_name])
->orderBy('create_time', 'desc')
->paginate(10)->toArray();
ps: Remember that the fields of the two tables should correspond to each other , You can't have more at the same time and less at the same time , You can't change the position
边栏推荐
- PostgreSQL weekly news - June 22
- Implementation and Simulation of ads131a04 ADC Verilog
- leetcode:370. 区间加法
- 实现inotify配合rsync实时备份
- 空间导电盘式滑环材料的选择
- 【ROS进阶篇】第四讲 ROS中的重名问题(节点、话题与参数)
- 炒股开户请问哪个券商佣金是最低最安全的
- The foundation and application of quantum machine learning: a concise literature review
- 「运维有小邓」Active Directory 密码过期通知功能
- In depth good article | yolov5+deepsort multi-target tracking in-depth interpretation and testing (including source code)
猜你喜欢

Exercise 8 Chapter 8 Verilog finite state machine design -4 Verilog quartus Modelsim

导航 习题【微机原理】【习题】

Information system project manager -- Chapter VII examination questions of project cost management over the years

verilog实现串口通信发送到数码管

解释PBR纹理贴图(texture-maps)

「运维有小邓」审核并分析文件和文件夹访问权限

yolov6训练自己的数据记录+yolov5对比测试

Chainsafe cross chain bridge deployment tutorial

导航 实验【微机原理】【实验】

习近平在湖北武汉考察时强调 把科技的命脉牢牢掌握在自己手中 不断提升我国发展独立性自主性安全性
随机推荐
The foundation and application of quantum machine learning: a concise literature review
《强化学习周刊》第51期:PAC、ILQL、RRL&无模型强化学习集成于微电网络格控制:综述与启示
【ROS进阶篇】第三讲 ROS文件系统与分布式通信
Explain PBR texture maps
"Xiaodeng" ad domain delegation for operation and maintenance
路由汇总带来的三层环路-解决实验
leetcode:307. Area and retrieval - array modifiable
Common methods of string class
「运维有小邓」Active Directory批量用户创建
Implementing LDAP proxy service with haproxy + keepalive
我的创作纪念日
【云原生实战】KubeSphere实战——多租户系统实战
直播预告 | PostgreSQL 内核解读系列第一讲:PostgreSQL 系统概述
推荐书籍--白夜行
HAproxy + Keepalive实现LDAP代理服务
AI scene Storage Optimization: yunzhisheng supercomputing platform storage practice based on juicefs
Detailed description of gaussdb (DWS) complex and diverse resource load management methods
CORDIC based Signal Processor desgn
【ROS进阶篇】第四讲 ROS中的重名问题(节点、话题与参数)
How to evaluate iFLYTEK AI translation pen P20 series? Is it worth buying?