SO whats the difference between just:
AndCode:SELECT * from table where field like bob
I've always used the second, but whats the difference?Code:SELECT * from table where field like '%bob%'
| SitePoint Sponsor |





SO whats the difference between just:
AndCode:SELECT * from table where field like bob
I've always used the second, but whats the difference?Code:SELECT * from table where field like '%bob%'
The first matches only bob. The second would match archbob or bobolink or anything with bob in the middle of it. % is a wildcard.
Actually I'm wrong. The first doesn't match anything because bob is a string and needs to be enclosed in quotes. In fact, you'll get a MySQL error.





So:
Is essentially the same as:Code:SELECT * from table where field like 'bob'
?Code:SELECT * from table where field='bob'
So is there a select option in string that do like if you have a string like "the bob", search for entries that contain either "the" or "bob"?
yes exactly





So is there a select state that does this in just mySQL?Originally Posted by Archbob
SELECT * FROM table WHERE entry LIKE '%the%' OR LIKE '%bob%';


WHERE entry LIKE '%the%' OR entry LIKE '%bob%';
Ah right... thanks r... little overlook there...![]()





Thanks, but thats not what I was talking about. I was asking if mySQL had a select that automatically string through a string and split it into individual words by the space.


no, there isn't
Hi. Sorry dont understand what you mean by auto string through a string and split. Could you explain what you mean ? Cause im also learning SQL and would be glad to find out moreOriginally Posted by Archbob
![]()
Singapore Web Hosting Forum - http://www.sgwebhostingtalk.com
Singapore Soccer - http://www.singaporesoccer.com
Music Forum and Lyrics - http://www.musicpowered.com
Dota Allstars Forum - http://www.dota-allstars.info




you would need the PHP function explode() (or the equivelant in other languages), which puts a string into an array, split by a delimiter.Originally Posted by Archbob





I'm mainly concerned about spaces so split would be good enough here.
Bookmarks