• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Requete with several like and where

#1
[eluser]Unknown[/eluser]
French :
Bonjour,
je souhaite réaliser une requête de recherche qui va rechercher un post en filtrant sur une catégorie sélection avant.
La recherche se fera sur le nom et le content.
Voici ce que je souhaite obtenir :
English :
Hello,
I want to make a search query that will search by filtering a post on a category selection before.
The research will be on name and content.
Here's what I want to:

Code:
SELECT *
FROM posts
WHERE posts.categoryid  =  '15'
AND  namepost  LIKE '%là%'
OR  posts.categoryid  =  '15'
AND content  LIKE '%là%'
J'ai essayer avec active record :
Code:
$this->db->where($conditions);
$this->db->like('namepost', $champsSerach);
$this->db->or_like('content', $champsSerach);
$this->db->where($conditions);
Mais j'obtiens :
Code:
SELECT *
FROM posts
WHERE posts.categoryid  =  '20'
AND posts.categoryid  =  '20'
AND  namepost  LIKE '%la%'
OR  content  LIKE '%la%'
A need your help please because i try lots things with where, or_where, etc.

#2
[eluser]Rodrigo Alexandre[/eluser]
try:

Code:
$this->db->where("(a.field LIKE '%$result%' OR b.field LIKE '%$result%')");
$this->db->where('c.field = '%$result%'');

#3
[eluser]Unknown[/eluser]
thx for () because I did not know you can make :
where condition = x and (item1 like %xxx% or item2 like %xxx%)
I did as :
where condition = x and item1 like %xxx% or condition = x and item2 like %xxx%

more complexe and repetition.
so thx lots

#4
[eluser]CroNiX[/eluser]
There will be a way to natively do this with active record on the next release.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.