0
我想了解以下活動記錄模式與常規sql語言的關聯。您是否可以在CodeIgniter中解釋以下活動記錄數據庫?
$get_it = $this -> db -> select('i.*,SUM(o.qty * o.price) AS total')
->from('invoices i, users u,orders o')
->where('u.usr_name',$user)
->where('u.usr_id = i.user_id')
->where('o.invoice_id = i.id')
->group_by('o.invoice_id')
->get();
是否有人可以將其轉換爲SQL語言至少?這將是一個很大的幫助。
IMO這個查詢包含一個邏輯錯誤 - 分組和選擇這樣的。 –
其實它工作正常,我只是想知道如果這段代碼是用sql查詢寫的。 –
你可能使用MySQL作爲實際的DB,它允許像這樣的查詢(在非嚴格模式下)。其他數據庫引擎會引發錯誤。 –