2016-02-05 11 views
0

執行與操作我用代碼點火器多連接查詢執行多個搜索,所以我進行3 or_like query.But有一個「OR」默認每個or_like查詢之間放置在由代碼igniter.But實際上我想執行'AND'操作之間them.Please幫我。 由於如何查詢兩個OR_LIKE之間的笨

+1

可以請你發佈一些你的代碼? – Drudge

+1

顯示您的查詢,然後問你的問題。另外,如果你按預期告訴你想要什麼? –

回答

0

我們可以做到這一點很簡單的笨版本3.0

例如,

$this ->db ->select('*'); 
    $this ->db ->where('age',$age); 
    $this ->db ->where('country',$country); 
    $this->db->group_start(); 
    $this ->db ->or_where('state',$state); 
    $this ->db ->or_where('district',$district); 
    $this->db->group_end(); 
    $query=$this ->db ->get('pg_reg'); 
0

or_like由codeignitor到多個實例由OR連接提供。所以,我認爲沒有辦法用AND取代OR。這是另一個可以嘗試的解決方案。

而不是使用 「喜歡」 和 「or_like」 使用where子句如下

$this->db->where('location LIKE', '%'.$your_location.'%'); 
$this->db->where('city LIKE', '%'.$your_city.'%'); 
+0

SELECT * FROM''pg_personaldet' LEFT pe' JOIN''pg_reg' ON r''r'.'rid' ='pe'.'rid' LEFT JOIN''pg_education' ON ed''ed'.'rid' ='pe'.'rid' WHERE'ed'.'education' LIKE '%3%' 和'ed'.'education' LIKE '%9%' 和'ed'.'occupation' LIKE '%17%'根據你的代碼,我得到了這段代碼,但我需要在教育表和職業表中的類似操作之間或在教育和職業表之間執行AND操作。在我的程序'$ your_location'是數組元素(即$ arr [$ i]在循環中執行,並在該循環中執行此查詢)。 –

+0

我在查詢中看不到任何職業表。你可以通過編輯問題添加一段查詢代碼嗎?所以它將有助於更多的調試。 – PHPExpert