Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 231729
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:57:27+00:00 2026-05-11T19:57:27+00:00

I have title (varchar), description (text), keywords (varchar) fields in my mysql table. I

  • 0

I have title (varchar), description (text), keywords (varchar) fields in my mysql table.

I kept keywords field as I thought I would be searching in this field only. But I now require to search among all three fields. so for keywords “word1 word2 word3”, my query becomes

SELECT * FROM myTable
WHERE (
name LIKE '%word1%' OR description LIKE '%word1%' OR keywords LIKE '%word1%' 
OR name LIKE '%word2%' OR description LIKE '%word2%' OR keywords LIKE '%word2%' 
OR name LIKE '%word3%' OR description LIKE '%word3%' OR keywords LIKE '%word3%') 
AND status = 'live'

Looks a bit messy but this works. But now I need to implement synonym search. so for a given word assuming there are a few synonyms available this query becomes more messy as I loop through all of the words. As the requirements are getting clearer, I will need to join this myTable to some other tables as well.

So

  • Do you think the above way is messy and will cause problems as the data grow?

  • How can I avoid above mess? Is there any cleaner solution I can go by? Any example will help me.

  • Is there any other method/technique you can recommend to me?

With thanks

EDIT

@Peter Stuifzand suggested me that I could create one search_index table and store all 3 fields (title,keyword,desc) info on that and do full text search. I understand that additionally this table will include reference to myTable primary key as well.

But my advanced search may include joining mytable with Category table, geographic_location table (for searching within 10, 20 miles etc), filtering by someother criteria and of course, sorting of search results. Do you think using mysql fulltext will not slow it down?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T19:57:27+00:00Added an answer on May 11, 2026 at 7:57 pm

    When your queries are getting out of hand, it’s sometimes better to write parts of it in SQL and other parts in your programming language of choice.

    And you could also use fulltext search for searching. You can create separate table with all fields that you want to search and add the FULLTEXT modifier.

    CREATE TABLE `search_index` (
        `id` INT NOT NULL,
        `data` TEXT FULLTEXT,
    );
    
    SELECT `id` FROM `search_index` WHERE MATCH(`data`) AGAINST('word1 word2 word3');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this Table structure: Id int not null --PK Title varchar(50) ParentId int
I have a table: MyTable config as XML title as varchar(255) In MyTable.config I
Assuming two columns in a MySQL (MyISAM) table: title VARCHAR(1500) url VARCHAR(155) I want
If I have a table with a title column and 3 bit columns (f1,
Let's say I have a table like this (this is just a simplified example,
Ok this is a new one for me. Basically I have a table articles:
I have two tables: Unit: UnitId int PK Title varchar UnitOption: UnitOptionId int PK
I have following 2 tables Channels: Id int PK Title varchar SubChannels: ChannelId int
i have a table in MySql as: CREATE TABLE products ( sub_product_id int(10) NOT
How can I make my window not have a title bar but appear in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.