如何将 mysql 查询转换为 laravel querybuilder
how to convert mysql query to laravel querybuilder
我尝试将我的查询转换为 laravel
查询生成器,但我无法成功,我的查询在 mysql
中,如下所示:
SELECT p.seller, p.purchase_date, p.report_no FROM purchases AS p UNION SELECT ps.seller, ps.purchase_date, ps.report_no FROM purchase_solds AS ps ORDER BY purchase_date DESC
那么如何将其转换为 laravel 查询生成器或 laravel eloquent?
你试过了吗
$purchases = DB::table('purchases')
->select('seller', 'purchase_date', 'report_no');
$purchase_solds = DB::table('purchase_solds')
->select('seller', 'purchase_date', 'report_no')
->union($purchases)
->orderBy('purchase_date', 'desc')
->get();
我尝试将我的查询转换为 laravel
查询生成器,但我无法成功,我的查询在 mysql
中,如下所示:
SELECT p.seller, p.purchase_date, p.report_no FROM purchases AS p UNION SELECT ps.seller, ps.purchase_date, ps.report_no FROM purchase_solds AS ps ORDER BY purchase_date DESC
那么如何将其转换为 laravel 查询生成器或 laravel eloquent?
你试过了吗
$purchases = DB::table('purchases')
->select('seller', 'purchase_date', 'report_no');
$purchase_solds = DB::table('purchase_solds')
->select('seller', 'purchase_date', 'report_no')
->union($purchases)
->orderBy('purchase_date', 'desc')
->get();