這是我的 php sql 代碼如何在 laravel 7 中實現(xiàn)它......請任何人幫助我......$results = $mysqli->query("SELECT a.ID,a.nm,b.nm as under,IFNULL(a.openingbalance,'0') AS openingbalance,a.drcr,a.bankacno,
a.bankifsccode,a.address,a.workphone,a.mobile,a.email,a.contactperson FROM maccountgroup a,
maccountgroup b WHERE a.parent_id=b.ID AND a.GL='L' and a.ACTIVE='Y' AND b.natureid = 1 AND a.comp_code = '".$_SESSION['comp_code']."'");
1 回答

隔江千里
TA貢獻(xiàn)1906條經(jīng)驗 獲得超10個贊
您應(yīng)該看看join是如何工作的。您要做的是與同一張表進(jìn)行連接。
還要看看join在 Laravel 上是如何工作的。所以對于您的查詢,有不同的方法可以做到這一點,這里是一個例子:
DB::table('maccountgroup?as?a') ??->join('maccountgroup?as?b',?'a.parent_id',?'b.ID') ??->where('a.GL',?'L') ??->where('b.ACTIVE',?'Y') ??->where('b.natureid',?1) ??->where('a.comp_code',?$request->comp_code)? ??->get();
- 1 回答
- 0 關(guān)注
- 131 瀏覽
添加回答
舉報
0/150
提交
取消