这是我的MySQL查询,如何在CodeIgniter中编写?

时间:2017-01-27 10:47:55

标签: php mysql codeigniter

这是我的MySQL查询以及如何在CodeIgniter中编写

SELECT distinct a.user_name
FROM wl_customers a
    INNER JOIN tbl_bid b ON a.customers_id = b.customers_id
    INNER JOIN tbl_portfolio c ON b.portfolio_id=c.portfolio_id 
WHERE c.portfolio_id='16'

3 个答案:

答案 0 :(得分:1)

尝试这样。在表之间使用连接。

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
LoginTest.groovy: 11: unable to resolve class com.vsi.icareos.client.home.HomePage
@ line 11, column 1.
import com.vsi.icareos.client.home.HomePage
^

LoginTest.groovy: 22: unable to resolve class LoginByPwdPage 
@ line 22, column 2.
LoginByPwdPage loginPage
^

LoginTest.groovy: 35: unable to resolve class LoginByPwdPage 
     @ line 35, column 13.
       loginPage=new LoginByPwdPage(browser,Consts.PAGE_ID)
          ^
3 errors

了解更多阅读文档https://www.codeigniter.com/userguide3/database/query_builder.html

答案 1 :(得分:0)

使用有效记录

    $this->db->select('distinct a.user_name');
    $this->db->from('wl_customers as a'); 
    $this->db->join('tbl_bid as b','a.customers_id=b.customers_id');
    $this->db->join('tbl_portfolio as c','b.portfolio_id=c.portfolio_id');
    $this->db->where('c.portfolio_id',16,false);
    $query = $this->db->get();

答案 2 :(得分:-2)

$query = $this->db->query("
SELECT MAX(A.BID),B.* FROM tbl_bid A INNER JOIN wl_customers B ON A.customers_id=B.customers_id
WHERE portfolio_id='16'
");