如何在codeigniter中使用下面给出的SQL语句?
如何在codeigniter中使用下面给出的SQL如何在codeigniter中使用下面给出的SQL语句?,codeigniter,Codeigniter,如何在codeigniter中使用下面给出的SQL select * from borrow_book where isbn=(select isbn from add_book where author='$author) 试试这个 $query = $this->db ->select("*") ->from("borrow_book") ->where("isbn=(select isbn from add_
select *
from borrow_book
where isbn=(select isbn
from add_book
where author='$author)
试试这个
$query = $this->db
->select("*")
->from("borrow_book")
->where("isbn=(select isbn from add_book where author='".$this->db->escape_str($author)."')",NULL,false)
->get();
我只想补充一点,我不熟悉您的数据库结构,但我认为大多数情况下,连接比子选择更好
$query= $this->db->query("SELECT borrow_book.*
FROM borrow_book, add_book
WHERE borrow_book.isbn= add_book.isbn AND add_book.author = '$author'");
$result= $query->result_array();
return $result;