How can be better to select from db all users that have name begining from "A" ? - 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: How can be better to select from db all users that have name begining from "A" ? (/showthread.php?tid=2119) |
How can be better to select from db all users that have name begining from "A" ? - El Forum - 07-17-2007 [eluser]New One[/eluser] for example i have db 'users' and field 'name' How can be better to select from db all users that have name begining from "A" ? $this->db->where('name',"like '%A'"); $data['query'] = $this->db->get('users'); but i think that something is wrong here :$this->db->where('name',"like '%A'"); please help How can be better to select from db all users that have name begining from "A" ? - El Forum - 07-17-2007 [eluser]Seppo[/eluser] $this->db->like("name","A%"); How can be better to select from db all users that have name begining from "A" ? - El Forum - 07-17-2007 [eluser]New One[/eluser] Thanks. But now the new problem is : I have a $temp (it can be A or B or Z etc.) how can i use it now? $this->db->like("name”,"$temp%"); or $this->db->like("name”,".$temp.%"); or $this->db->like("name”,"$temp.%"); Doesn't help. How can be better to select from db all users that have name begining from "A" ? - El Forum - 07-17-2007 [eluser]MattKern[/eluser] try $this->db->like("name”,$temp."%"); It should work - I am not on a machine I can actually test it on. Sorry.... How can be better to select from db all users that have name begining from "A" ? - El Forum - 07-17-2007 [eluser]New One[/eluser] looks like it doesn't helps. it search the symbol in all string. |