Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Searching name from database

Tags:

php

mysql

I have the name in mysql database table like Mohan Krishna. How we can search for that name using php with searching like mohankrishna name?

like image 482
lalith222 Avatar asked Jan 16 '23 03:01

lalith222


2 Answers

SELECT * FROM tablename
WHERE LOWER(REPLACE(name,' ','')) LIKE LOWER('%mohankrishna%')
like image 51
Shehzad Bilal Avatar answered Jan 18 '23 23:01

Shehzad Bilal


I'm not 100% sure, but could be a good approach.

One way would be, using the full text functionality of MySQL.

Another way by using LIKE in your SELECT-query just like.

SELECT * FROM users WHERE username LIKE "mohankrishna";

But I'm not really familiar with this and I don't know how tolerant MySQL is to give you the exact record.

like image 41
sascha Avatar answered Jan 19 '23 00:01

sascha