When I fetch the records from the LIKE the query returns no results but when I fetch records from the equal to (=) then the query returns results.

Following user name are stored in the database:

(1) `~@#$%'\|/?.><^&%@()-_+-:
(2) (){}[]|\/?"*&^%$#@sujeet`


I am searching the records from the LIKE operator as the following ways:

(1)

SELECT * FROM user WHERE user LIKE '%`~@#$%''\\|/?.><^&%@()-_+-:%'

(2)

SELECT * FROM user WHERE user LIKE '%(){}[]|\\/?"*&^%$#@test`%'

And I am fetching the records from the equal to (=) operator as the following ways:

(1)

SELECT * FROM user WHERE user = '`~@#$%''\\|/?.><^&%@()-_+-:'

(2)

SELECT * FROM user WHERE user = '(){}[]|\\/?"*&^%$#@test`'

But when I am fetching the records from the LIKE operator the the query returns no results and when I am fetching records from the equal to operator then the query returns results. Both of the SQL query is shown above.

Please suggest how I will solve this problem.

Thank You
Sujeet.

Which DB is it (MySQL, MS SQL, Oracle, MS Access)?

I am using Mysql. Also the username is:

(){}[]|\/?"*&^%$#@test`

not (){}[]|\/?"*&^%$#@sujeet`

Thank You
Sujeet.

Which DB is it (MySQL, MS SQL, Oracle, MS Access)?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.