Welcome Guest, Not a member yet? Register   Sign In
i have a problem with $this->db->like
#1

[eluser]minhbu[/eluser]
i want to search 1 number in db with column is string
example
i have string id_news= "1,2,3,4,5,6,11,12,14,19"
when i use $this->db->like("id_news",1)
result is 1,11,12,14,19 but i want to result is 1
Please help me.
#2

[eluser]Dam1an[/eluser]
Assuming the numbers will always be in order, you could do something like
Code:
$this->db->query("SELECT * FROM `news` WHERE `id_news` = '1' OR `id_news` LIKE '1,%'");

The first one will catch just 1 on its own, and the second part will get any strings starting off with the number 1 and any number of numbers following
#3

[eluser]minhbu[/eluser]
$this->db->query("SELECT * FROM `news` WHERE `id_news` = '1' OR `id_news` LIKE '1,%'");
if i have a string id_news="11,3,57,6,7,12,1"
i think i try use "select * from news where 1 in(id_news)"




Theme © iAndrew 2016 - Forum software by © MyBB