Search code examples
mysql

in MySQL how to do broaden the search


need to search by including terms to more result set of relevant

broaden the search by using scenario Table Below

Title
Introduction to MySQL
Getting Started with SQL
MySQL vs. PostgreSQL
Advanced SQL Techniques
Web Development with Python and MySQL
Data Modeling and Design
Troubleshooting MySQL Performance

if user search MySQL

i need result like this

Title
Introduction to MySQL
Getting Started with SQL
MySQL vs. PostgreSQL
Advanced SQL Techniques
Full-Text Searching in MySQL
Web Development with Node.js and MySQL
Troubleshooting MySQL Performance

result dont have Data Modeling and Design as it dont have SQL

Hope Like dint work


Solution

  • SELECT *
    FROM your_table_name
    WHERE MATCH(title)AGAINST('MySQL' WITH QUERY EXPANSION);
    

    For full-text search, need to do full-text index for the columns you to search.

    For example:

    ALTER TABLE your_table_name  
        ADD FULLTEXT INDEX title_fulltext_search (title);
    

    For more kindly click here for official documents