簡體   English   中英

如何使用codeigniter活動記錄編寫與此類似的查詢?

[英]How to write query similar to this with codeigniter active record?

這是我想用codeigniter編寫的mysql查詢

SELECT r.reciept_no,r.loan_no,r.amount_paid,c.mem_name  
FROM receipts r, customer c 
WHERE r.loan_no = c.loan_no AND reciept_no = '$receipt_id'

任何幫助都會很棒

問候

從我的頭頂

$this->db->select('receipts.reciept_no');
$this->db->select('receipts.loan_no');
$this->db->select('receipts.amount_paid');
$this->db->select('receipts.reciept_no');
$this->db->select('customer.mem_name');
$this->db->where('reciept_no', $receipt_id);
$this->db->join('customer', 'receipts.loan_no = customer.loan_no');
$this->db->get('receipts');

在這里加入蜜蜂鍵

只是一個小的修改:

$sql = 'r.reciept_no,r.loan_no,r.amount_paid,r.reciept_no,c.mem_name';

$this->db->select($sql)
->where('reciept_no', $receipt_id)
->join('customer as c', 'r.loan_no = c.loan_no')
->get('receipts as r');

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM