当前位置:网站首页>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
边栏推荐
- Xiaomi written test real question 1
- WPF measurement string display size
- Live broadcast preview | PostgreSQL kernel Interpretation Series Lecture 1: overview of PostgreSQL system
- Enter the year and month to find the total number of days in the month
- 「运维有小邓」Active Directory批量用户创建
- Is it safe to open an account with flush for stock trading?
- MES系统与ERP如何集成?本文告诉你答案
- GoAhead WebServer移植
- 量子机器学习的基础和应用:一个简明文献综述
- 如何审核 Active Directory 用户账户更改?
猜你喜欢

Advances in computational imaging

Sentinel's quick start takes you through flow control in three minutes

LSF-bsub命令

项目中退出操作

High energy live broadcast, a gathering of celebrities! We invite you to explore bizdevops.

Logical structure and physical structure

计算成像前沿进展

Selection of materials for space conductive disc slip ring

Practical guide to GStreamer application development (V)

【ROS进阶篇】第四讲 ROS中的重名问题(节点、话题与参数)
随机推荐
String字符串的存储原理
Basic qualities of management personnel
leetcode:238. Product of arrays other than itself
Stm32cubemx learning (6) external interrupt experiment
At least 3 years for learning amplifier?
How to judge the quality of conductive slip ring from its appearance
如何在 SAP BTP ABAP 编程环境里直接调用 ABAP On-Premises 系统的 RFC 函数
Analysis of the underlying architecture of spark storage system - spark business environment practice
Common methods of string class
How to call RFC function of ABAP on premises system directly in SAP BTP ABAP programming environment
PostgreSQL每周新聞—6月22日
Goahead webserver migration
Is it safe to open an account with flush for stock trading?
GoAhead 翻译—Active Server Pages
Topic39——78. 子集
CORDIC based Signal Processor desgn
期末复习【微机原理】
Shell implementation of Memcache cache cache hit rate monitoring script
阿里云发布《中国机器人产业图谱(2022)》,122页pdf
《强化学习周刊》第51期:PAC、ILQL、RRL&无模型强化学习集成于微电网络格控制:综述与启示