SELECT * FROM table_name where match ( column1, column2.. ) against ( 'keyword1 keyword2')
ALTER TABLE `sql_tutorial`.`student` ADD FULLTEXT `my_ind` (`name`)
Creating table with FULLTEXT Index
CREATE TABLE IF NOT EXISTS `student` (
`id` int(2) NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL DEFAULT '',
`class` varchar(10) NOT NULL DEFAULT '',
`mark` int(3) NOT NULL DEFAULT '0',
`sex` varchar(6) NOT NULL DEFAULT 'male',
UNIQUE KEY `id` (`id`),
FULLTEXT KEY `my_ind` (`name`,`class`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=36 ;
To add FULLTEXT index your table type must be of MyISAM. Table type InnoDB doesn't not support FULLTEXT index. However MySQL version 5.6 onwards support for FULLTEXT index is available.
The used table type doesn't support FULLTEXT indexes
ALTER TABLE `sql_tutorial`.`plus2_file_php` ADD FULLTEXT `my_ind` (`title` ,`des`)
SELECT * FROM `student` WHERE match(name) against('alex')
require "config.php"; // Database Connection
Then we will collect the search string
$search_string=trim($_REQUEST['keyword']);
Now using the above search string we will develop the query.
$sql="select * from $table_name where match(name,class) against('$search_string') ";
Now using the same query we will display the records returned.
echo "<table class='t1'>
<th>ID</th><th>NAME</th><th>CLASS</th><th>SEX</th><th>MARK</th>";
foreach ($dbo->query($sql) as $row) {$m=$i%2;
echo "<tr class='r$m'><td>$row[id]</td><td>$row[name]</td><td>$row[class]</td><td>$row[sex]</td><td>$row[mark]</td></tr>";
$i=$i+1;}
echo "</table>";
We used student table for this example. You can use any other table with more data.

Author
🎥 Join me live on YouTubePassionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.