DB Active record Solution need - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: DB Active record Solution need (/showthread.php?tid=12670) |
DB Active record Solution need - El Forum - 10-27-2008 [eluser]bijon[/eluser] Hi, i want to get a search user list against a particular id and match the search string either first_name or last_name. so i do the active record like : Code: //*****so many code before// i fournd that my query generate string is : Code: select * from table_name where id=1 and first_name like '%a%' or last_name like '%a%' Though there is no name match against the id 1 , i still get output where output id shows may be 3 or 4. So finally i found that if only last_name match then it returns the output . Not check the id. SO I Change the query string where add parenthesis (). I describe below my required query.THIS give me the correct output. Code: select * from table_name where id=1 and (first_name like '%a%' or last_name like '%a%') thanks saidur http://saidur.wordpress.com |