DB Active record Solution need |
[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 |
Welcome Guest, Not a member yet? Register Sign In |