Thread: Tech Dumb SQL question
View Single Post
Old 09-07-2015, 12:42 PM  
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,053
Quote:
Originally Posted by drclockwork View Post
tl;dr: the code snippets.

It's been a little while since I've had to do any heavy lifting with MySQL, but if I recall correctly, when you use % in your database query, it assumes that you're looking for something before the beginning of the string. Therefore anything that starts with your string, and nothing before it, it will return 0 results.
That is incorrect.

https://dev.mysql.com/doc/refman/5.0...functions.html
% matches any number of characters, even zero characters.

from our examples above:

sql=Select id, url, title from test_table where title LIKE '%transvestite threesome tea party%'

when we go to execute that we get back a:

Sql returned 1 rows

Rec 1 Title: transvestite threesome tea party matched
__________________
All cookies cleared!
sarettah is online now   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote