01-12-2008, 08:11 AM
[eluser]CodeIgniter Fan[/eluser]
I am developing matrimonial site on which I am query the database on multiple talbes which contains both AND & OR operator Now this is my query
SELECT DISTINCT pinfo.id, pinfo.name FROM partner_primary_info as pinfo INNER JOIN partner_religious_background relbackg ON pinfo.id=relbackg.candidate_id INNER JOIN partner_astro_data astro ON relbackg.candidate_id=astro.candidate_id INNER JOIN partner_family_details familyd ON astro.candidate_id=familyd.candidate_id INNER JOIN partner_life_style lifestyle ON familyd.candidate_id=lifestyle.candidate_id INNER JOIN partner_education_occupation eduocc ON lifestyle.candidate_id=eduocc.candidate_id INNER JOIN partner_residence resi ON eduocc.candidate_id=resi.candidate_id WHERE pinfo.gender = 'Male' AND pinfo.age >= '25' AND pinfo.age <= '27' AND pinfo.marital_status = 'Single' AND pinfo.no_of_children = 'None' OR pinfo.no_of_children = '' AND pinfo.height >= '4.05' AND pinfo.height <= '7.00' AND pinfo.physical_status = '2'
I am generating the query string using active record class now in the above query if I want to add brackets on both side of no_of_children field that I had shown bold above in query.
Is it possible to add brackets using active record class or database class ? I need it because otherwise my query doesn't produces expected result.
I am developing matrimonial site on which I am query the database on multiple talbes which contains both AND & OR operator Now this is my query
SELECT DISTINCT pinfo.id, pinfo.name FROM partner_primary_info as pinfo INNER JOIN partner_religious_background relbackg ON pinfo.id=relbackg.candidate_id INNER JOIN partner_astro_data astro ON relbackg.candidate_id=astro.candidate_id INNER JOIN partner_family_details familyd ON astro.candidate_id=familyd.candidate_id INNER JOIN partner_life_style lifestyle ON familyd.candidate_id=lifestyle.candidate_id INNER JOIN partner_education_occupation eduocc ON lifestyle.candidate_id=eduocc.candidate_id INNER JOIN partner_residence resi ON eduocc.candidate_id=resi.candidate_id WHERE pinfo.gender = 'Male' AND pinfo.age >= '25' AND pinfo.age <= '27' AND pinfo.marital_status = 'Single' AND pinfo.no_of_children = 'None' OR pinfo.no_of_children = '' AND pinfo.height >= '4.05' AND pinfo.height <= '7.00' AND pinfo.physical_status = '2'
I am generating the query string using active record class now in the above query if I want to add brackets on both side of no_of_children field that I had shown bold above in query.
Is it possible to add brackets using active record class or database class ? I need it because otherwise my query doesn't produces expected result.