Please someone tell me the command for searching in whole table of a database,
like If I want to search whole table (not by any single field or column)
For example, I want something similar command to this
SELECT * FROM `school_table` like '%mohan%'
Please note, I know the other command for searching but that is only for searching in any particular row, for example.
SELECT * FROM `school_table` where name like '%mohan%'
can you give an example of what you want returned from the search?
yes sure, For example, I want to return all the columns (e.g. ID, Name etc.) of a table, where any field name is consisting of my name.
My name is mohan.
So, if a table consists of mohan anywhere in it, it should return me that column.
ok, say your table has 3 columns in it - col1, col2 and col3
select * from tblName
where col1 like '%mohan%' or col2 like '%mohan%' or col3 like '%mohan%';
will return all the columns where mohan is in any of them.
What is the command of searching this thing in a table of mysql?
For example, I have a record mohan in one of my mysql-table, and when i search the database by the name mohan, it returns the rows wherever the column has name mohan in it.
select * from names where name like '%mohan%'
This is very simple.
But I felt said when I searched by the name moh an, there was no rows returned.
and the same thing happened when i searched moh-an.
select * from names where name like '%mo han%'
select * from names where name like '%mo-han%'
Is there any way to search all the characters in that column name and figure out what i want?
not based on the example you gave, no
well, for starters, you wouldn't need to look into any column that is numeric, like the id column
so you wouldn't search all the columns, just the string ones
Thanks to all of you.
I got the way.
Oh sir, some other method to get some similar results ?????
you could do this --
WHERE name LIKE CONCAT('%',REPLACE(REPLACE('mo han',' ',''),'-',''),'%')
but you should probably remove the spaces and dashes in your application language (php?) before searching