avir
asked on
codeigniter query returning too many results
I've created a codeigniter query for a search function using the query builder class and it returns too many results. How could I adjust it to get a more specific result set?
My codeigniter query (shortened version):
function get_print_search() {
$match = $this->input->post('search ');
$this->db->like('Exhibitio nE','Prove nance Online');
$this->db->like('Departmen tE','Jewis h Art');
$this->db->like('TitleE',$ match);
$this->db->or_like('Artist E',$match) ;
$this->db->or_like('Object NameE',$ma tch);
$query = $this->db->get('combh');
return $query->result();
}
The type of sql query I would like to use:
SELECT TitleE, ArtistE, ObjectNameE FROM combh WHERE (ExhibitionE Like 'Provenance Online' AND DepartmentE Like 'Jewish Art' ) AND (TitleE Like $match OR ArtistE Like $match OR ObjectNameE Like $match)
There seems to be some confusion in the codeigniter query about where the parenthesis separate the query parts in the sql query. The current codeigniter query returns all the TitleE, ArtistE and ObjectNameE results from 'Provenance Online' and I would like to get just the 'Provenance Online' results from 'Jewish Art'.
Thanks for any assistance.
My codeigniter query (shortened version):
function get_print_search() {
$match = $this->input->post('search
$this->db->like('Exhibitio
$this->db->like('Departmen
$this->db->like('TitleE',$
$this->db->or_like('Artist
$this->db->or_like('Object
$query = $this->db->get('combh');
return $query->result();
}
The type of sql query I would like to use:
SELECT TitleE, ArtistE, ObjectNameE FROM combh WHERE (ExhibitionE Like 'Provenance Online' AND DepartmentE Like 'Jewish Art' ) AND (TitleE Like $match OR ArtistE Like $match OR ObjectNameE Like $match)
There seems to be some confusion in the codeigniter query about where the parenthesis separate the query parts in the sql query. The current codeigniter query returns all the TitleE, ArtistE and ObjectNameE results from 'Provenance Online' and I would like to get just the 'Provenance Online' results from 'Jewish Art'.
Thanks for any assistance.
Can you give me few rows and the expected output?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Worked great. Thanks.