How can a FULLTEXT index be created to match multiple columns in a MySQL table?

To create a FULLTEXT index that matches multiple columns in a MySQL table, you can use the ALTER TABLE statement to add the index to the desired columns. This allows you to perform efficient full-text searches across those columns in your queries.

// Connect to the database
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "database";
$conn = new mysqli($servername, $username, $password, $dbname);

// Create FULLTEXT index on multiple columns
$sql = "ALTER TABLE your_table_name ADD FULLTEXT(column1, column2, column3)";
if ($conn->query($sql) === TRUE) {
    echo "FULLTEXT index created successfully";
} else {
    echo "Error creating FULLTEXT index: " . $conn->error;
}

// Close the connection
$conn->close();