Prodip Kirtania
Prodip Kirtania

Reputation: 99

wildcard search with multiple parameters in MYSQL?

I have a table named 'contacts'. which consists of some columns. One of the column's name is 'name'. I want to create a wildcard search using multiple search parameter in name column in one query.
How do I find multiple records using LIKE phrase?

I have tried this code.

SELECT * FROM contacts WHERE NAME LIKE '%Sudipta%', '%Hasanuzzaman%', '%Jawad%';

I expected This result:

id    |  name             |
----------------------------
254   | Sudipta Kumar     | 
280   | Sudipta Chowdhury | 
402   | Hasanuzzaman Khan | 
452   | MD. Hasanuzzaman  | 
469   | Jawad Karim       |

But this error message has been displayed:

Error Code: 1064
You have an error in your SQL syntax;
check the manual that corresponds to your MariaDB server version for the right syntax to use near ' '%Hasanuzzaman%', '%Jawad%' LIMIT 0, 1000' at line 1

Please tell me the query to do the above action...

Upvotes: 1

Views: 526

Answers (1)

Balvinder Singh
Balvinder Singh

Reputation: 320

Use LIKE OR Operator in query

SELECT * FROM contacts WHERE NAME LIKE '%Sudipta%' OR NAME LIKE '%Hasanuzzaman%' OR NAME LIKE '%Jawad%';

Hope this help you

Upvotes: 2

Related Questions