I am having the same problem.

This Query:

SELECT 'haystack needle haystack' LIKE concat('%', 'needle', '%')

returns 1

However, this query does not work correctly If you generalize is to include a database column:

SELECT * FROM MyTable WHERE 'haystack needle haystack' LIKE CONCAT('%', NeedleColumn, '%')

This query does not work either:

SELECT * FROM MyTable WHERE LOCATE(NeedleColumn, 'haystack needle haystack') <> 0

The two previous queries fail even when an exact match exists:

SELECT LOCATE('haystack needle haystack', 'haystack needle haystack')

returns 1

SELECT * FROM MyTable WHERE NeedleColumn = 'haystack needle haystack'

Returns

NeedleColumn
---------------------
haystack needle haystack

The following query (incorrectly) returns no records:

SELECT * FROM MyTable WHERE LOCATE(NeedleColumn, 'haystack needle haystack') <> 0

As far as I can tell, this is a bug. can someone suggest a workaround?



On Sunday, March 23, 2003, at 07:23 AM, Jakob Vedel Adeltoft wrote:

I wan't to search for all rows that match a value.

I have these rows:
URL                                             Name
'http://www.microsoft.com/kb/'  Microsoft Knowledgebase
'http://www.microsoft.com/search/'      Microsoft Search

Now I wan't to find all occurences where any of above URL columns exist in the string 'http://www.microsoft.com/kb/knowledgeb.asp?id=3&strse=12'.

I tried to use LIKE:
SELECT URL, Name
FROM websites
WHERE 'http://www.microsoft.com/kb/knowledgeb.asp?id=3&strse=12' LIKE (URL + '%');


But this doesn't return any results. I would like the following as output:
'http://www.microsoft.com/kb/' Microsoft Knowledgebase



Plz help me:)


/Jakob

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to