LIKE % Operator

LIKE % Operator

am 13.01.2006 22:33:41 von coosa

Dear all,

I want to perform a simple search for a query such as:

SELECT *
FROM SOME_TABLE
WHERE SOME_TABLE.SOME_COLUMN LIKE '%SOME_KEYWORD%'

The same statement if implemented in a stored procedure would look
similar like this:
CREATE PROCEDURE sp_FindKeyword (IN SOME_KEYWORD AS VARCHAAR(55))
BEGIN
SELECT *
FROM SOME_TABLE
WHERE SOME_TABLE.SOME_COLUMN LIKE '%' + SOME_KEYWORD + '%' ;
END

But this does't work ....
I know I could manipulate the '%' before passing the parameter using
the interface language such as php, asp, ..etc. but is there a way this
can be done using MySql 5 itself?

Best regards

Re: LIKE % Operator

am 13.01.2006 22:49:57 von Bill Karwin

"coosa" wrote in message
news:1137188021.686491.22540@f14g2000cwb.googlegroups.com...
> WHERE SOME_TABLE.SOME_COLUMN LIKE '%' + SOME_KEYWORD + '%' ;

MySQL uses the CONCAT() function to concatenate string. For example:

WHERE SOME_TABLE.SOME_COLUMN LIKE CONCAT('%', SOME_KEYWORD, '%')

String concatenation, strangely, is nonstandard in many RDBMS
implementations. In the ANSI SQL standard, the string concatenation
operator is ||, but few RDBMS's seem to do it that way.

Regards,
Bill K.