Welcome Guest, Not a member yet? Register   Sign In
Using $this->db->like without %
#1

[eluser]Computerzworld[/eluser]
Hello,
How can I use $this->db->like without % to be added on either of side that means my query should be something like this.

Code:
select * from tablename where name like 'ci';

But $this->db->like contains options as match,before,after,both. But what about not using wildcards? Please help me.Thanks in advance.
#2

[eluser]TheFuzzy0ne[/eluser]
Have you tried running that query on your database to see how many results it returns? Try it, that might answer your question. Smile
#3

[eluser]xwero[/eluser]
why not use "where name = 'ci'" ?
#4

[eluser]TheFuzzy0ne[/eluser]
Exactly so. LIKE is used for wildcard comparisons. LIKE without a wildcard, is like running a car without fuel. It simply won't work.
#5

[eluser]Computerzworld[/eluser]
hmm Smile the reason why i am gonna use it is that i read somewhere when using string comparisons use like with no wildcards around them it will be more effective than traditional '=' comparison.
#6

[eluser]TheFuzzy0ne[/eluser]
It depends which way you look at it. If you see not making any matches as more efficient, then yes, I guess it is... Where did you read this?

LIKE was created for specifically for wildcard matches. I would have thought that = would actually be a lot quicker as it's making a straight match, and not having to use any kind of algorithm on the resulting string.
#7

[eluser]xwero[/eluser]
In some cases like gets different results than =, for example 'a' = 'a ' gets another result than 'a' like 'a ' but normally you get this by trimming the posted value and using =.




Theme © iAndrew 2016 - Forum software by © MyBB