On Saturday, March 29, 2003, at 07:41 AM, Trevor Smith wrote:
2. your syntax just seems wrong. This should be:
SELECT * FROM MyTable WHERE NeedleColumn LIKE '%needle%';
to search for the string 'needle' anywhere in NeedleColumn, if that's what you were looking for.
I'm jumping in mid-stream so excuse me if I'm confused.
The syntax was correct for the task.
Lets say for example, that you have a database of bad words:
CREATE TABLE BadWords (Word CHAR( 10 ) NOT NULL); INSERT INTO BadWords (Word) VALUES ('Fudge'); INSERT INTO BadWords (Word) VALUES ('Dang'); INSERT INTO BadWords (Word) VALUES ('Darn');
You want to validate an arbitrary string against the database to find out if it contains any bad words.
example string that contains a bad word: 'Darn Database"
To find which bad words were used in the phrase you are checking, You would issue a query like this:
SELECT * FROM BadWords WHERE 'Darn Database' LIKE CONCAT('%', Word, '%')
which returns
Word ---- Darn
When I just tried this small example, it worked perfectly which really surprised me. I spent about 2 hours testing this every which way before my previous post, too.
Looking into it more, I found that the reason that it didn't work before was that I was using PHPMyAdmin under IE for the mac. I browsed a table to get a key value to test with and copied the value I wanted to search for from the browser and pasted it into my test query.
The string in my test that I thought I was using was:
"Mozilla/4.0 (compatible; MSIE 5.02; Windows 98)"
When I pasted this string into my text editor and told it to add escape codes for hidden characters, I got this:
"Mozilla/4.0\0xCA(compatible;\0xCAMSIE\0xCA5.02;\0xCAWindows\0xCA98)"
It seems that PHPMyAdmin converts spaces in the query results into entities for html display. On the Mac with IE, when you copy a string that contains from the browser, it seems to get converted into the character \0xCA instead of the normal space character.
Everything works fine if I search for the correct string containing normal spaces.
I feel stupid for not double checking my queries outside of PHPMyAdmin before posting my last message.
Does this help you, Jakob?
-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]